OSDN Git Service

shared: Check HCI packet type before sending it to btdev
authorMarcel Holtmann <marcel@holtmann.org>
Wed, 11 Sep 2013 14:13:31 +0000 (07:13 -0700)
committerMarcel Holtmann <marcel@holtmann.org>
Wed, 11 Sep 2013 14:13:31 +0000 (07:13 -0700)
src/shared/hciemu.c

index af8007c..90c21f3 100644 (file)
@@ -162,10 +162,16 @@ static gboolean receive_btdev(GIOChannel *channel, GIOCondition condition,
        fd = g_io_channel_unix_get_fd(channel);
 
        len = read(fd, buf, sizeof(buf));
-       if (len < 0)
+       if (len < 1)
                return FALSE;
 
-       btdev_receive_h4(btdev, buf, len);
+       switch (buf[0]) {
+       case BT_H4_CMD_PKT:
+       case BT_H4_ACL_PKT:
+       case BT_H4_SCO_PKT:
+               btdev_receive_h4(btdev, buf, len);
+               break;
+       }
 
        return TRUE;
 }