[xiph-commits] r14488 - trunk/vorbis-tools/ogg123

giles at svn.xiph.org giles at svn.xiph.org
Tue Feb 12 11:35:42 PST 2008


Author: giles
Date: 2008-02-12 11:35:41 -0800 (Tue, 12 Feb 2008)
New Revision: 14488

Modified:
   trunk/vorbis-tools/ogg123/cfgfile_options.c
Log:
Correct check for strtol failure broken in the last commit.

Also check for integer value overflow.


Modified: trunk/vorbis-tools/ogg123/cfgfile_options.c
===================================================================
--- trunk/vorbis-tools/ogg123/cfgfile_options.c	2008-02-12 16:00:30 UTC (rev 14487)
+++ trunk/vorbis-tools/ogg123/cfgfile_options.c	2008-02-12 19:35:41 UTC (rev 14488)
@@ -27,7 +27,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <limits.h> /* for INT_MAX / INT_MIN */
+#include <limits.h> /* for INT/LONG_MIN/MAX */
 #include <errno.h>
 
 #include "cfgfile_options.h"
@@ -320,10 +320,13 @@
       case opt_type_int:
 	if (!value || *value == '\0')
 	  return parse_badvalue;
+	errno = 0;
 	tmpl = strtol (value, &endptr, 0);
-	if (((tmpl == INT_MIN || tmpl == INT_MAX) && errno == ERANGE)
+	if (((tmpl == LONG_MIN || tmpl == LONG_MAX) && errno == ERANGE)
 	    || (*endptr != '\0'))
 	  return parse_badvalue;
+	if ((tmpl > INT_MAX) || (tmpl < INT_MIN))
+	  return parse_badvalue;
 	opt->found++;
 	*(int *) opt->ptr = tmpl;
 	break;



More information about the commits mailing list