Have "get_positive_int()" really check for positive integers, not just
non-negative integers. Get rid of unused "get_positive_int()" routine in "gtk/capture_dlg.c". svn path=/trunk/; revision=4796
This commit is contained in:
parent
8bd63530ed
commit
b767826991
|
@ -1,7 +1,7 @@
|
|||
/* capture_dlg.c
|
||||
* Routines for packet capture windows
|
||||
*
|
||||
* $Id: capture_dlg.c,v 1.60 2002/02/24 03:33:05 guy Exp $
|
||||
* $Id: capture_dlg.c,v 1.61 2002/02/24 06:01:03 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -654,35 +654,6 @@ cap_prep_fs_destroy_cb(GtkWidget *win, gpointer data)
|
|||
gtk_widget_destroy(GTK_WIDGET(win));
|
||||
}
|
||||
|
||||
static int
|
||||
get_positive_int(const char *string, const char *name)
|
||||
{
|
||||
long number;
|
||||
char *p;
|
||||
|
||||
number = strtol(string, &p, 10);
|
||||
/*
|
||||
* XXX - we allow extra stuff after 0, so that we don't have
|
||||
* problems with the "(Infinite)" value.
|
||||
*/
|
||||
if (p == string || (*p != '\0' && number != 0)) {
|
||||
simple_dialog(ESD_TYPE_CRIT, NULL,
|
||||
"The specified %s is not a decimal number.", name);
|
||||
return -1;
|
||||
}
|
||||
if (number < 0) {
|
||||
simple_dialog(ESD_TYPE_CRIT, NULL,
|
||||
"The specified %s is a negative number.", name);
|
||||
return -1;
|
||||
}
|
||||
if (number > INT_MAX) {
|
||||
simple_dialog(ESD_TYPE_CRIT, NULL,
|
||||
"The specified %s is too large (greater than %d).", name, INT_MAX);
|
||||
return -1;
|
||||
}
|
||||
return number;
|
||||
}
|
||||
|
||||
static void
|
||||
capture_prep_ok_cb(GtkWidget *ok_bt, gpointer parent_w) {
|
||||
GtkWidget *if_cb, *snap_cb, *snap_sb, *promisc_cb, *filter_te,
|
||||
|
|
12
gtk/main.c
12
gtk/main.c
|
@ -1,6 +1,6 @@
|
|||
/* main.c
|
||||
*
|
||||
* $Id: main.c,v 1.235 2002/02/24 03:33:05 guy Exp $
|
||||
* $Id: main.c,v 1.236 2002/02/24 06:01:03 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -1114,6 +1114,11 @@ get_positive_int(const char *string, const char *name)
|
|||
name, string);
|
||||
exit(1);
|
||||
}
|
||||
if (number == 0) {
|
||||
fprintf(stderr, "ethereal: The specified %s \"%s\" is zero\n",
|
||||
name, string);
|
||||
exit(1);
|
||||
}
|
||||
if (number > INT_MAX) {
|
||||
fprintf(stderr, "ethereal: The specified %s \"%s\" is too large (greater than %d)\n",
|
||||
name, string, INT_MAX);
|
||||
|
@ -1447,11 +1452,6 @@ main(int argc, char *argv[])
|
|||
#ifdef HAVE_LIBPCAP
|
||||
has_autostop_count = TRUE;
|
||||
autostop_count = get_positive_int(optarg, "packet count");
|
||||
if (autostop_count == 0) {
|
||||
fprintf(stderr, "ethereal: The specified packet count \"%s\" is zero\n",
|
||||
optarg);
|
||||
exit(1);
|
||||
}
|
||||
#else
|
||||
capture_option_specified = TRUE;
|
||||
arg_error = TRUE;
|
||||
|
|
20
tethereal.c
20
tethereal.c
|
@ -1,6 +1,6 @@
|
|||
/* tethereal.c
|
||||
*
|
||||
* $Id: tethereal.c,v 1.124 2002/02/24 03:33:04 guy Exp $
|
||||
* $Id: tethereal.c,v 1.125 2002/02/24 06:01:01 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -200,13 +200,18 @@ get_positive_int(const char *string, const char *name)
|
|||
exit(1);
|
||||
}
|
||||
if (number < 0) {
|
||||
fprintf(stderr, "tethereal: The specified %s \"%s\" is a negative number\n",
|
||||
name, string);
|
||||
fprintf(stderr, "tethereal: The specified %s is a negative number\n",
|
||||
name);
|
||||
exit(1);
|
||||
}
|
||||
if (number == 0) {
|
||||
fprintf(stderr, "tethereal: The specified %s is zero\n",
|
||||
name);
|
||||
exit(1);
|
||||
}
|
||||
if (number > INT_MAX) {
|
||||
fprintf(stderr, "tethereal: The specified %s \"%s\" is too large (greater than %d)\n",
|
||||
name, string, INT_MAX);
|
||||
fprintf(stderr, "tethereal: The specified %s is too large (greater than %d)\n",
|
||||
name, INT_MAX);
|
||||
exit(1);
|
||||
}
|
||||
return number;
|
||||
|
@ -445,11 +450,6 @@ main(int argc, char *argv[])
|
|||
case 'c': /* Capture xxx packets */
|
||||
#ifdef HAVE_LIBPCAP
|
||||
packet_count = get_positive_int(optarg, "packet count");
|
||||
if (packet_count == 0) {
|
||||
fprintf(stderr, "tethereal: The specified packet count \"%s\" is zero\n",
|
||||
optarg);
|
||||
exit(1);
|
||||
}
|
||||
#else
|
||||
capture_option_specified = TRUE;
|
||||
arg_error = TRUE;
|
||||
|
|
Loading…
Reference in New Issue