You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ji...@apache.org on 2008/02/29 17:54:21 UTC
svn commit: r632386 - /httpd/mod_bw/trunk/mod_bw.c
Author: jim
Date: Fri Feb 29 08:54:10 2008
New Revision: 632386
URL: http://svn.apache.org/viewvc?rev=632386&view=rev
Log:
more complete number checking
Modified:
httpd/mod_bw/trunk/mod_bw.c
Modified: httpd/mod_bw/trunk/mod_bw.c
URL: http://svn.apache.org/viewvc/httpd/mod_bw/trunk/mod_bw.c?rev=632386&r1=632385&r2=632386&view=diff
==============================================================================
--- httpd/mod_bw/trunk/mod_bw.c (original)
+++ httpd/mod_bw/trunk/mod_bw.c Fri Feb 29 08:54:10 2008
@@ -163,6 +163,20 @@
/* Module declaration */
module AP_MODULE_DECLARE_DATA bw_module;
+static int bw_is_number(const char *num)
+{
+ if (!num) {
+ return 0;
+ }
+ while (*num) {
+ if (!apr_isdigit(*num))
+ return 0;
+ }
+ num++;
+ }
+ return 1;
+}
+
/*---------------------------------------------------------------------*
* Configurations Directives *
*---------------------------------------------------------------------*/
@@ -201,7 +215,7 @@
bandwidth_config *conf = (bandwidth_config *) s;
int temp;
- if (pack && *pack && apr_isdigit(*pack))
+ if (bw_is_number(pack))
temp = atol(pack);
else
return "Invalid argument";
@@ -220,7 +234,7 @@
bandwidth_config *conf = (bandwidth_config *) s;
int temp;
- if (err && *err && apr_isdigit(*err))
+ if (bw_is_number(err))
temp = atol(err);
else
return "Invalid argument";
@@ -245,7 +259,7 @@
apr_status_t rv;
char msgbuf[120];
- if (maxc && *maxc && apr_isdigit(*maxc))
+ if (bw_is_number(maxc))
temp = atoi(maxc);
else
return "Invalid argument";
@@ -301,7 +315,7 @@
apr_status_t rv;
char msgbuf[120];
- if (bw && *bw && apr_isdigit(*bw))
+ if (bw_is_number(bw))
temp = atol(bw);
else
return "Invalid argument";
@@ -354,8 +368,12 @@
char *where = (char *) apr_pstrdup(cmd->pool, from);
apr_status_t rv;
char msgbuf[120];
+ const char *pc = bw;
- if (bw && *bw && (*bw == '-' || apr_isdigit(*bw)))
+ if (pc && (*pc == '-'))
+ pc++;
+
+ if (bw_is_number(pc))
temp = atol(bw);
else
return "Invalid argument";
@@ -401,16 +419,20 @@
bandwidth_config *conf = (bandwidth_config *) s;
bw_sizel *a;
long int temp, tsize;
+ const char *pc = bw;
if (strlen(file) < 1)
return "You must enter a filetype (use * for all)";
- if (bw && *bw && (*bw == '-' || apr_isdigit(*bw)))
+ if (pc && (*pc == '-'))
+ pc++;
+
+ if (bw_is_number(pc))
temp = atol(bw);
else
return "Invalid argument";
- if (size && *size && apr_isdigit(*size))
+ if (bw_is_number(size))
tsize = atol(size);
else
return "Invalid argument";