[radvd-devel-l] [RADVD PATCH] Accept value >= 0x80000000 on 32-bit archs

YOSHIFUJI Hideaki / 吉藤英明 yoshfuji at linux-ipv6.org
Mon Aug 21 11:44:42 EDT 2006


Hello.

We could not set value >= 0x80000000 (e.g. to AdvRetransTimer)
on 32-bit architecture machines.

Use strtoul() instead of atoi() (or strtol()).

Bug was reported by Mitsuru Chinen <CHINEN at jp.ibm.com>.

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji at linux-ipv6.org>

Index: scanner.l
===================================================================
RCS file: /work/cvsroot/radvd/scanner.l,v
retrieving revision 1.12
diff -u -r1.12 scanner.l
--- scanner.l	29 Mar 2006 12:32:10 -0000	1.12
+++ scanner.l	21 Aug 2006 15:25:32 -0000
@@ -110,7 +110,17 @@
 			return IPV6ADDR;
 		}
 
-{number}	{ yylval.num = atoi(yytext); return NUMBER; }
+{number}	{
+			unsigned long lnum;
+			char *endp;
+			lnum = strtoul(yytext, &endp, 10);
+			if (*yytext == '\0' || *endp != '\0')
+				return T_BAD_TOKEN;
+			if (lnum > 0xFFFFFFFFUL)
+				return T_BAD_TOKEN;	/* XXX */
+			yylval.num = lnum;
+			return NUMBER;
+		}
 
 {snum}		{ yylval.snum = atoi(yytext); return SIGNEDNUMBER; }
 

-- 
YOSHIFUJI Hideaki @ USAGI Project  <yoshfuji at linux-ipv6.org>
GPG-FP  : 9022 65EB 1ECF 3AD1 0BDF  80D8 4807 F894 E062 0EEA



More information about the radvd-devel-l mailing list