diff options
author | Dario Lombardo <lomato@gmail.com> | 2016-08-31 10:14:33 +0200 |
---|---|---|
committer | Dario Lombardo <lomato@gmail.com> | 2016-09-16 14:21:16 +0000 |
commit | d67c1db3f2b16185d7cff250e098f48d94883f0e (patch) | |
tree | f111269e33ea8b0ac29532c18e2ce16762f4f515 /extcap/sshdump.c | |
parent | 2492fe41ba165738aa8667ebfe7f9e96f69ef350 (diff) |
extcap: make extcap use the ws_strtoi/u functions.
Change-Id: Id75c72eba869c8a0f413ce8b5d6329ce172aed1f
Reviewed-on: https://code.wireshark.org/review/17415
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Roland Knall <rknall@gmail.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Diffstat (limited to 'extcap/sshdump.c')
-rw-r--r-- | extcap/sshdump.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/extcap/sshdump.c b/extcap/sshdump.c index f5173c381e..9e1752cb3f 100644 --- a/extcap/sshdump.c +++ b/extcap/sshdump.c @@ -25,9 +25,10 @@ #include "config.h" #include <extcap/extcap-base.h> +#include <extcap/ssh-base.h> #include <wsutil/interface.h> #include <wsutil/file_util.h> -#include <extcap/ssh-base.h> +#include <wsutil/strtoi.h> #include <errno.h> #include <string.h> @@ -95,7 +96,7 @@ static void ssh_loop_read(ssh_channel channel, int fd) return; } -static char* local_interfaces_to_filter(const unsigned int remote_port) +static char* local_interfaces_to_filter(const guint16 remote_port) { GSList* interfaces = local_interfaces_to_list(); char* filter = interfaces_list_to_filter(interfaces, remote_port); @@ -104,7 +105,7 @@ static char* local_interfaces_to_filter(const unsigned int remote_port) } static ssh_channel run_ssh_command(ssh_session sshs, const char* capture_bin, const char* iface, const char* cfilter, - unsigned long int count) + const guint32 count) { gchar* cmdline; ssh_channel channel; @@ -140,7 +141,7 @@ static ssh_channel run_ssh_command(ssh_session sshs, const char* capture_bin, co cfilter = default_filter; quoted_filter = g_shell_quote(cfilter); if (count > 0) - count_str = g_strdup_printf("-c %lu", count); + count_str = g_strdup_printf("-c %u", count); cmdline = g_strdup_printf("%s -i %s -w - -f %s %s", quoted_bin, quoted_iface, quoted_filter, count_str ? count_str : ""); @@ -165,7 +166,7 @@ static ssh_channel run_ssh_command(ssh_session sshs, const char* capture_bin, co static int ssh_open_remote_connection(const char* hostname, const unsigned int port, const char* username, const char* password, const char* sshkey, const char* sshkey_passphrase, const char* iface, const char* cfilter, const char* capture_bin, - const unsigned long int count, const char* fifo) + const guint32 count, const char* fifo) { ssh_session sshs = NULL; ssh_channel channel = NULL; @@ -307,7 +308,7 @@ int main(int argc, char **argv) int option_idx = 0; int i; char* remote_host = NULL; - unsigned int remote_port = 22; + guint16 remote_port = 22; char* remote_username = NULL; char* remote_password = NULL; char* remote_interface = NULL; @@ -315,7 +316,7 @@ int main(int argc, char **argv) char* sshkey = NULL; char* sshkey_passphrase = NULL; char* remote_filter = NULL; - unsigned long int count = 0; + guint32 count = 0; int ret = EXIT_FAILURE; extcap_parameters * extcap_conf = g_new0(extcap_parameters, 1); char* help_header = NULL; @@ -381,8 +382,7 @@ int main(int argc, char **argv) break; case OPT_REMOTE_PORT: - remote_port = (unsigned int)strtoul(optarg, NULL, 10); - if (remote_port > 65535 || remote_port == 0) { + if (!ws_strtou16(optarg, NULL, &remote_port) || remote_port == 0) { g_warning("Invalid port: %s", optarg); goto end; } @@ -426,7 +426,10 @@ int main(int argc, char **argv) break; case OPT_REMOTE_COUNT: - count = strtoul(optarg, NULL, 10); + if (!ws_strtou32(optarg, NULL, &count)) { + g_warning("Invalid value for count: %s", optarg); + goto end; + } break; case ':': |