stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r449118 - /incubator/stdcxx/trunk/util/cmdopt.cpp
Date Fri, 22 Sep 2006 22:59:46 GMT
Author: sebor
Date: Fri Sep 22 15:59:45 2006
New Revision: 449118

URL: http://svn.apache.org/viewvc?view=rev&rev=449118
Log:
2006-09-22  Andrew Black  <ablack@roguewave.com>

	* cmdopt.cpp (parse_limit_opts): Restrict sub-option values to
	non-negative integers.
	(eval_options): Ditto for -t, --exit, and --sleep. Fix off-by
	one error in logic for --ignore and --ulimit, leading to incorrect
	parsing.

Modified:
    incubator/stdcxx/trunk/util/cmdopt.cpp

Modified: incubator/stdcxx/trunk/util/cmdopt.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/util/cmdopt.cpp?view=diff&rev=449118&r1=449117&r2=449118
==============================================================================
--- incubator/stdcxx/trunk/util/cmdopt.cpp (original)
+++ incubator/stdcxx/trunk/util/cmdopt.cpp Fri Sep 22 15:59:45 2006
@@ -333,6 +333,10 @@
 
                 arg += limits [i].len + 1;
 
+                if (!isdigit (*arg)) {
+                    return 1;
+                }
+
                 char *end;
                 const long lim = strtol (arg, &end, 10);
 
@@ -461,8 +465,10 @@
             optname = opt_timeout;
             optarg  = get_short_val (argv, &i);
             if (optarg) {
+                if (!isdigit (*optarg))
+                    bad_value (optname, optarg);
                 timeout = strtol (optarg, &end, 10);
-                if (*end || timeout < 0 || errno)
+                if (*end || errno)
                     bad_value (optname, optarg);
             }
             else
@@ -512,6 +518,8 @@
                 optname = opt_exit;
                 optarg  = get_long_val (argv, &i, sizeof opt_exit - 1);
                 if (optarg && *optarg) {
+                    if (!isdigit (*optarg))
+                        bad_value (optname, optarg);
                     const long code = strtol (optarg, &end, 10);
                     if ('\0' == *end && !errno)
                         exit (code);
@@ -528,6 +536,8 @@
                 optname = opt_sleep;
                 optarg  = get_long_val (argv, &i, sizeof opt_sleep - 1);
                 if (optarg && *optarg) {
+                    if (!isdigit (*optarg))
+                        bad_value (optname, optarg);
                     const long nsec = strtol (optarg, &end, 10);
                     if ('\0' == *end && 0 <= nsec && !errno) {
                         rw_sleep (nsec);
@@ -549,10 +559,10 @@
                     }
                 }
             }
-            else if (   sizeof opt_ignore <= arglen
+            else if (   sizeof opt_ignore - 1 <= arglen
                      && !memcmp (opt_ignore, argv [i], sizeof opt_ignore - 1)) {
                 optname = opt_ignore;
-                optarg  = get_long_val (argv, &i, sizeof opt_ignore);
+                optarg  = get_long_val (argv, &i, sizeof opt_ignore - 1);
                 if (optarg && *optarg) {
                     const long signo = get_signo (optarg);
                     if (0 <= signo) {
@@ -563,7 +573,7 @@
                     }
                 }
             }
-            else if (   sizeof opt_ulimit <= arglen
+            else if (   sizeof opt_ulimit - 1 <= arglen
                      && !memcmp (opt_ulimit, argv [i], sizeof opt_ulimit - 1)) {
                 optname = opt_ulimit;
                 optarg  = get_long_val (argv, &i, sizeof opt_ulimit - 1);



Mime
View raw message