am7xxx: detect unexpected responses to AM7XXX_PACKET_TYPE_DEVINFO requests
authorAntonio Ospite <ospite@studenti.unina.it>
Fri, 7 Dec 2012 11:22:45 +0000 (12:22 +0100)
committerAntonio Ospite <ospite@studenti.unina.it>
Fri, 7 Dec 2012 11:47:39 +0000 (12:47 +0100)
Under some conditions, some devices like Philips/Sagemcom PPX projectors
return a strangely small packet (e.g. an AM7XXX_PACKET_TYPE_POWER with
header_data_len == 2) in reply to an AM7XXX_PACKET_TYPE_DEVINFO, hence
NOT providing useful device info.

src/am7xxx.c

index 47f79ea..bc671f1 100644 (file)
@@ -752,6 +752,13 @@ AM7XXX_PUBLIC int am7xxx_get_device_info(am7xxx_device *dev,
        if (ret < 0)
                return ret;
 
+       if (h.packet_type != AM7XXX_PACKET_TYPE_DEVINFO) {
+               error(dev->ctx, "expected packet type: %d, got %d instead!\n",
+                     AM7XXX_PACKET_TYPE_DEVINFO, h.packet_type);
+               errno = ENOTSUP;
+               return -ENOTSUP;
+       }
+
        device_info->native_width = h.header_data.devinfo.native_width;
        device_info->native_height = h.header_data.devinfo.native_height;
 #if 0