OSDN Git Service

gobex: Ignore unexpected responses (which can occur when aborting)
authorJohan Hedberg <johan.hedberg@intel.com>
Sat, 9 Jul 2011 13:26:46 +0000 (16:26 +0300)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 4 Dec 2012 21:22:01 +0000 (22:22 +0100)
gobex/gobex.c
unit/test-gobex.c

index b4e809a..40c06cf 100644 (file)
@@ -752,6 +752,11 @@ static gboolean incoming_data(GIOChannel *io, GIOCondition cond,
                header_offset = rsp_header_offset(opcode);
        } else {
                opcode = obex->rx_buf[0] & ~FINAL_BIT;
+               /* Unexpected response -- fail silently */
+               if (opcode > 0x1f && opcode < 0xff) {
+                       obex->rx_data = 0;
+                       return TRUE;
+               }
                header_offset = req_header_offset(opcode);
                obex->rx_last_op = opcode;
        }
index 7a7cbe9..6d14b51 100644 (file)
@@ -565,7 +565,7 @@ static void test_recv_unexpected(void)
 
        g_obex_set_disconnect_function(obex, unexpected_disconn, &err);
 
-       req = g_obex_packet_new(G_OBEX_RSP_SUCCESS, TRUE, NULL);
+       req = g_obex_packet_new(G_OBEX_RSP_CONTINUE, TRUE, NULL);
        len = g_obex_packet_encode(req, buf, sizeof(buf));
        g_assert_cmpint(len, >=, 0);