[GRASS-dev] db yyparse integer overflow
Markus Metz
markus.metz.giswork at gmail.com
Tue Apr 9 05:03:12 PDT 2013
I found a rather cryptic integer overflow when importing double
precision attributes into a dbf table: the values are recognized as
integer if there are no decimal places, e.g. 4294967296. The proposed
fix for trunk is
--->
Index: lib/db/sqlp/sqlp.l
===================================================================
--- lib/db/sqlp/sqlp.l (revision 55660)
+++ lib/db/sqlp/sqlp.l (working copy)
@@ -127,9 +127,19 @@
***************************************/
%}
[0-9]+ {
+ double floatval;
+
yylval.intval = atoi(yytext);
/* yylval.strval = (char*)strdup(yytext); */
- return INTNUM;
+ floatval = atof(yytext);
+ if ((double)yylval.intval == floatval) {
+ return INTNUM;
+ }
+ else {
+ /* integer overflow */
+ yylval.floatval = floatval;
+ return FLOATNUM;
+ }
}
%{
/***************************************
<---
but I am not sure about side effects.
Markus M
More information about the grass-dev
mailing list