From 7f5cb418d3a9d0389a14f3f07f5e8240dff7b476 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Sat, 9 Jul 2011 16:26:46 +0300 Subject: [PATCH] gobex: Ignore unexpected responses (which can occur when aborting) --- gobex/gobex.c | 5 +++++ unit/test-gobex.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gobex/gobex.c b/gobex/gobex.c index b4e809abc..40c06cfbd 100644 --- a/gobex/gobex.c +++ b/gobex/gobex.c @@ -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; } diff --git a/unit/test-gobex.c b/unit/test-gobex.c index 7a7cbe9de..6d14b516e 100644 --- a/unit/test-gobex.c +++ b/unit/test-gobex.c @@ -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); -- 2.47.3