]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
usb-mtp: fix string length for filename when writing metadata
authorDaniel P. Berrangé <berrange@redhat.com>
Mon, 15 Apr 2019 15:45:01 +0000 (16:45 +0100)
committerGerd Hoffmann <kraxel@redhat.com>
Thu, 2 May 2019 06:29:33 +0000 (08:29 +0200)
The ObjectInfo 'length' field provides the length of the
wide character string filename. This is then converted to
a multi-byte character string. This may have a different
byte count to the wide character string. We should use the
C string length of the multi-byte string instead.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-id: 20190415154503.6758-2-berrange@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/usb/dev-mtp.c

index 99548b012d1ff1ec8b40e0453ed3311db61fc06a..6b7d1296e4300c62eb03d5c8bd49e40b8c9801e0 100644 (file)
@@ -1721,7 +1721,7 @@ static void usb_mtp_write_metadata(MTPState *s, uint64_t dlen)
         return;
     }
 
-    o = usb_mtp_object_lookup_name(p, filename, dataset->length);
+    o = usb_mtp_object_lookup_name(p, filename, -1);
     if (o != NULL) {
         next_handle = o->handle;
     }