current cgi.c,1.160,1.161
Fabian Keil <[email protected]>
| Newsgroups | gmane.comp.web.privoxy.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/ijbswa/current
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv27458
Modified Files:
cgi.c
Log Message:
get_number_param(): Simplify code by using strtol()
Index: cgi.c
===================================================================
RCS file: /cvsroot/ijbswa/current/cgi.c,v
retrieving revision 1.160
retrieving revision 1.161
diff -C2 -d -r1.160 -r1.161
*** cgi.c 18 Oct 2014 11:31:52 -0000 1.160
--- cgi.c 26 Feb 2016 12:32:26 -0000 1.161
***************
*** 808,813 ****
{
const char *param;
! char ch;
! unsigned value;
assert(csp);
--- 808,812 ----
{
const char *param;
! char *endptr;
assert(csp);
***************
*** 824,857 ****
}
! /* We don't use atoi because I want to check this carefully... */
!
! value = 0;
! while ((ch = *param++) != '\0')
{
! if ((ch < '0') || (ch > '9'))
! {
! return JB_ERR_CGI_PARAMS;
! }
!
! ch = (char)(ch - '0');
!
! /* Note:
! *
! * <limits.h> defines UINT_MAX
! *
! * (UINT_MAX - ch) / 10 is the largest number that
! * can be safely multiplied by 10 then have ch added.
! */
! if (value > ((UINT_MAX - (unsigned)ch) / 10U))
! {
! return JB_ERR_CGI_PARAMS;
! }
!
! value = value * 10 + (unsigned)ch;
}
- /* Success */
- *pvalue = value;
-
return JB_ERR_OK;
--- 823,832 ----
}
! *pvalue = (unsigned int)strtol(param, &endptr, 0);
! if (*endptr != '\0')
{
! return JB_ERR_CGI_PARAMS;
}
return JB_ERR_OK;
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140