[asterisk-commits] twilson: branch 10 r371398 - in /branches/10: ./ main/config.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Aug 16 17:50:18 CDT 2012


Author: twilson
Date: Thu Aug 16 17:50:12 2012
New Revision: 371398

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=371398
Log:
Handle integer over/under-flow in ast_parse_args

The strtol family of functions will return *_MIN/*_MAX on overflow. To
detect when an overflow has happened, errno must be set to 0 before
calling the function, then checked afterward.

(closes issue ASTERISK-20120)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/2073/
........

Merged revisions 371392 from http://svn.asterisk.org/svn/asterisk/branches/1.8

Modified:
    branches/10/   (props changed)
    branches/10/main/config.c

Propchange: branches/10/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: branches/10/main/config.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/main/config.c?view=diff&rev=371398&r1=371397&r2=371398
==============================================================================
--- branches/10/main/config.c (original)
+++ branches/10/main/config.c Thu Aug 16 17:50:12 2012
@@ -2652,8 +2652,9 @@
 			error = 1;
 			goto int32_done;
 		}
+		errno = 0;
 		x = strtol(arg, &endptr, 0);
-		if (*endptr || x < INT32_MIN || x > INT32_MAX) {
+		if (*endptr || errno || x < INT32_MIN || x > INT32_MAX) {
 			/* Parse error, or type out of int32_t bounds */
 			error = 1;
 			goto int32_done;
@@ -2699,8 +2700,9 @@
 			error = 1;
 			goto uint32_done;
 		}
+		errno = 0;
 		x = strtoul(arg, &endptr, 0);
-		if (*endptr || x > UINT32_MAX) {
+		if (*endptr || errno || x > UINT32_MAX) {
 			error = 1;
 			goto uint32_done;
 		}




More information about the asterisk-commits mailing list