]> git.proxmox.com Git - mirror_qemu.git/commitdiff
usb-mtp: Return error on suspicious TYPE_DATA packet from initiator
authorBandan Das <bsd@redhat.com>
Fri, 18 May 2018 18:49:03 +0000 (14:49 -0400)
committerGerd Hoffmann <kraxel@redhat.com>
Tue, 12 Jun 2018 10:08:12 +0000 (12:08 +0200)
CID 1390604
If the initiator sends a packet with TYPE_DATA set without
initiating a CMD_GET_OBJECT_INFO first, then usb_mtp_get_data
can trip on a null s->data_out.

Signed-off-by: Bandan Das <bsd@redhat.com>
Message-Id: <jpgr2m8ajfk.fsf_-_@linux.bootlegged.copy>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/usb/dev-mtp.c

index b0ab6a7912e1ed3d78a9f8d33f13cc6c8eb96af7..1ded7ac9a30478ba0b4e00f5dd4cf323a7ab39aa 100644 (file)
@@ -1700,6 +1700,11 @@ static void usb_mtp_get_data(MTPState *s, mtp_container *container,
     uint64_t dlen;
     uint32_t data_len = p->iov.size;
 
+    if (!d) {
+            usb_mtp_queue_result(s, RES_INVALID_OBJECTINFO, 0,
+                                 0, 0, 0, 0);
+            return;
+    }
     if (d->first) {
         /* Total length of incoming data */
         d->length = cpu_to_le32(container->length) - sizeof(mtp_container);