aboutsummaryrefslogtreecommitdiffstats
path: root/extcap
diff options
context:
space:
mode:
authorMichal Labedzki <michal.labedzki@tieto.com>2015-04-23 08:58:21 +0200
committerMichal Labedzki <michal.labedzki@tieto.com>2015-04-23 09:02:00 +0000
commit0e572cbcbf125ceb37d11638b5f05e646da1fc5d (patch)
tree2f046eb568a1c55426c70bb691a87e38667bcb98 /extcap
parent4ea4ddbe6a9bc9eda992f460cdd3862ff5334959 (diff)
androiddump: Fix warning about unneeded value
Value from strtol is not needed in this case, but compiler complains about it, so check if value range is valid and other possible error that can be detected. Change-Id: I6a8eeb6d2cb62c155772201000eca4c16bc8a555 Reviewed-on: https://code.wireshark.org/review/8172 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
Diffstat (limited to 'extcap')
-rw-r--r--extcap/androiddump.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/extcap/androiddump.c b/extcap/androiddump.c
index 22bc99fba6..46ccf9a87c 100644
--- a/extcap/androiddump.c
+++ b/extcap/androiddump.c
@@ -1140,10 +1140,18 @@ static int capture_android_bluetooth_hcidump(char *interface, char *fifo,
if (hex == 0x01) {
hex_data = new_hex_data;
- strtol(hex_data, &new_hex_data, 16);
+ hex = strtol(hex_data, &new_hex_data, 16);
+ if (hex < 0 || hex >= 256 || hex_data == new_hex_data) {
+ printf("ERROR: data format error: %s\n", strerror(errno));
+ return 101;
+ }
hex_data = new_hex_data;
- strtol(hex_data, &new_hex_data, 16);
+ hex = strtol(hex_data, &new_hex_data, 16);
+ if (hex < 0 || hex >= 256 || hex_data == new_hex_data) {
+ printf("ERROR: data format error: %s\n", strerror(errno));
+ return 101;
+ }
hex_data = new_hex_data;
hex = strtol(hex_data, &new_hex_data, 16);
@@ -1151,18 +1159,30 @@ static int capture_android_bluetooth_hcidump(char *interface, char *fifo,
raw_length = hex + 4;
} else if (hex == 0x04) {
hex_data = new_hex_data;
- strtol(hex_data, &new_hex_data, 16);
+ hex = strtol(hex_data, &new_hex_data, 16);
+ if (hex < 0 || hex >= 256 || hex_data == new_hex_data) {
+ printf("ERROR: data format error: %s\n", strerror(errno));
+ return 101;
+ }
hex_data = new_hex_data;
hex = strtol(hex_data, &new_hex_data, 16);
- raw_length = hex +3;
+ raw_length = hex + 3;
} else if (hex == 0x02) {
hex_data = new_hex_data;
- strtol(hex_data, &new_hex_data, 16);
+ hex = strtol(hex_data, &new_hex_data, 16);
+ if (hex < 0 || hex >= 256 || hex_data == new_hex_data) {
+ printf("ERROR: data format error: %s\n", strerror(errno));
+ return 101;
+ }
hex_data = new_hex_data;
- strtol(hex_data, &new_hex_data, 16);
+ hex = strtol(hex_data, &new_hex_data, 16);
+ if (hex < 0 || hex >= 256 || hex_data == new_hex_data) {
+ printf("ERROR: data format error: %s\n", strerror(errno));
+ return 101;
+ }
hex_data = new_hex_data;
hex = strtol(hex_data, &new_hex_data, 16);