androiddump: fix bug in socket retry (CID 1293391).

Change-Id: I61914d208e984d202506cdc885493e841e929990
Reviewed-on: https://code.wireshark.org/review/16948
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
This commit is contained in:
Dario Lombardo 2016-08-07 19:09:17 +02:00 committed by Peter Wu
parent 7596268b9b
commit b669ca75c4
1 changed files with 4 additions and 4 deletions

View File

@ -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;