From b669ca75c435d741920110a5d5e7822f55f899b0 Mon Sep 17 00:00:00 2001 From: Dario Lombardo Date: Sun, 7 Aug 2016 19:09:17 +0200 Subject: androiddump: fix bug in socket retry (CID 1293391). Change-Id: I61914d208e984d202506cdc885493e841e929990 Reviewed-on: https://code.wireshark.org/review/16948 Reviewed-by: Peter Wu Petri-Dish: Peter Wu Tested-by: Petri Dish Buildbot Reviewed-by: Michal Labedzki --- extcap/androiddump.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'extcap/androiddump.c') diff --git a/extcap/androiddump.c b/extcap/androiddump.c index e8e4287af9..a139b86162 100644 --- a/extcap/androiddump.c +++ b/extcap/androiddump.c @@ -1060,7 +1060,7 @@ static int capture_android_bluetooth_hcidump(char *interface, char *fifo, static char helpful_packet[PACKET_LENGTH]; gssize length; gssize used_buffer_length = 0; - socket_handle_t sock; + socket_handle_t sock = INVALID_SOCKET; const char *adb_transport = "0012""host:transport-any"; const char *adb_transport_serial_templace = "%04x""host:transport:%s"; const char *adb_shell_hcidump = "0013""shell:hcidump -R -t"; @@ -1079,7 +1079,6 @@ static int capture_android_bluetooth_hcidump(char *interface, char *fifo, int ms = 0; struct tm date; char direction_character; - int try_next = 0; SET_DATA(h4_header, value_own_pcap_bluetooth_h4_header, packet); @@ -1166,7 +1165,8 @@ static int capture_android_bluetooth_hcidump(char *interface, char *fifo, if (!strncmp(state_line_position, "Can't access device: Permission denied", 38)) { g_warning("No permission for command <%s>", adb_shell_hcidump); used_buffer_length = 0; - try_next += 1; + closesocket(sock); + sock = INVALID_SOCKET; break; } memmove(data, i_position, used_buffer_length - (i_position - data)); @@ -1176,7 +1176,7 @@ static int capture_android_bluetooth_hcidump(char *interface, char *fifo, } } - if (try_next == 1) { + if (sock == INVALID_SOCKET) { sock = adb_connect(adb_server_ip, adb_server_tcp_port); if (sock == INVALID_SOCKET) return EXIT_CODE_INVALID_SOCKET_4; -- cgit v1.2.3