forked from osmocom/wireshark
Use get_positive_int() to parse signed positive arguments.
Change-Id: Id17b56704f484abdf047a3d1b0775f7fa46eb380 Reviewed-on: https://code.wireshark.org/review/17507 Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
2a38dc74ed
commit
94d8250bd0
29
editcap.c
29
editcap.c
|
@ -76,6 +76,8 @@
|
|||
#endif
|
||||
|
||||
#include <wsutil/crash_info.h>
|
||||
#include <wsutil/clopts_common.h>
|
||||
#include <wsutil/cmdarg_err.h>
|
||||
#include <wsutil/filesystem.h>
|
||||
#include <wsutil/file_util.h>
|
||||
#include <wsutil/md5.h>
|
||||
|
@ -892,7 +894,6 @@ framenum_compare(gconstpointer a, gconstpointer b, gpointer user_data _U_)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef HAVE_PLUGINS
|
||||
/*
|
||||
* General errors are reported with an console message in editcap.
|
||||
*/
|
||||
|
@ -903,7 +904,16 @@ failure_message(const char *msg_format, va_list ap)
|
|||
vfprintf(stderr, msg_format, ap);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Report additional information for an error in command-line arguments.
|
||||
*/
|
||||
static void
|
||||
failure_message_cont(const char *msg_format, va_list ap)
|
||||
{
|
||||
vfprintf(stderr, msg_format, ap);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
static wtap_dumper *
|
||||
editcap_dump_open(const char *filename, guint32 snaplen,
|
||||
|
@ -975,6 +985,8 @@ main(int argc, char *argv[])
|
|||
char* init_progfile_dir_error;
|
||||
#endif
|
||||
|
||||
cmdarg_err_init(failure_message, failure_message_cont);
|
||||
|
||||
#ifdef _WIN32
|
||||
arg_list_utf_16to8(argc, argv);
|
||||
create_app_running_mutex();
|
||||
|
@ -1192,20 +1204,11 @@ main(int argc, char *argv[])
|
|||
break;
|
||||
|
||||
case 'i': /* break capture file based on time interval */
|
||||
secs_per_block = atoi(optarg);
|
||||
if (secs_per_block <= 0) {
|
||||
fprintf(stderr, "editcap: \"%s\" isn't a valid time interval\n\n",
|
||||
optarg);
|
||||
exit(1);
|
||||
}
|
||||
secs_per_block = get_positive_int(optarg, "time interval");
|
||||
break;
|
||||
|
||||
case 'I': /* ignored_bytes at the beginning of the frame for duplications removal */
|
||||
ignored_bytes = atoi(optarg);
|
||||
if(ignored_bytes <= 0) {
|
||||
fprintf(stderr, "editcap: \"%s\" isn't a valid number of bytes to ignore\n", optarg);
|
||||
exit(1);
|
||||
}
|
||||
ignored_bytes = get_positive_int(optarg, "number of bytes to ignore");
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
|
|
Loading…
Reference in New Issue