summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rbutil/ipodpatcher/ipodio-win32-scsi.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/rbutil/ipodpatcher/ipodio-win32-scsi.c b/rbutil/ipodpatcher/ipodio-win32-scsi.c
index 5843ce5d2f..81e2023f75 100644
--- a/rbutil/ipodpatcher/ipodio-win32-scsi.c
+++ b/rbutil/ipodpatcher/ipodio-win32-scsi.c
@@ -110,7 +110,10 @@ int ipod_scsi_inquiry(struct ipod_t* ipod, int page_code,
FALSE);
if (status) {
- memcpy(buf, sptwb.DataBuf, returned);
+ /* W32 sometimes returns more bytes with additional garbage.
+ * Make sure to not copy that garbage. */
+ memcpy(buf, sptwb.DataBuf,
+ (DWORD)bufsize >= returned ? returned : (DWORD)bufsize);
return 0;
} else {
return -1;