diff options
author | Guy Harris <guy@alum.mit.edu> | 2002-02-24 06:01:03 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2002-02-24 06:01:03 +0000 |
commit | b767826991ba30b900ae917a290927871bc62976 (patch) | |
tree | 02e8f9b9e89c525112f7f61cce532b6e6a4bee90 | |
parent | 8bd63530ed159d50e5375f1268b047d5e519c73b (diff) | |
download | wireshark-b767826991ba30b900ae917a290927871bc62976.tar.gz wireshark-b767826991ba30b900ae917a290927871bc62976.tar.bz2 wireshark-b767826991ba30b900ae917a290927871bc62976.zip |
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
-rw-r--r-- | gtk/capture_dlg.c | 31 | ||||
-rw-r--r-- | gtk/main.c | 12 | ||||
-rw-r--r-- | tethereal.c | 20 |
3 files changed, 17 insertions, 46 deletions
diff --git a/gtk/capture_dlg.c b/gtk/capture_dlg.c index e0ae080a1a..c5aa1eb0b1 100644 --- a/gtk/capture_dlg.c +++ b/gtk/capture_dlg.c @@ -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, diff --git a/gtk/main.c b/gtk/main.c index bfeceb4a1e..fde8e66c42 100644 --- a/gtk/main.c +++ b/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; diff --git a/tethereal.c b/tethereal.c index d7b2a764f8..33d7b82a7e 100644 --- a/tethereal.c +++ b/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; |