← Commit list

7018385fe

Manuel Novoa III
Manuel Novoa III
2004-01-25
FAILED Duration: 70s

Subject

Be stricter when converting strings to integers. Should fix the problem reported by Rob.

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

coreutils/expr.c+11 -9
@@ -157,15 +157,17 @@ static void tostring (VALUE *v)
static int toarith (VALUE *v)
{
if(v->type == string) {
- int i;
-
- /* Don't interpret the empty string as an integer. */
- if (v->u.s == 0)
- return 0;
- i = atoi(v->u.s);
- free (v->u.s);
- v->u.i = i;
- v->type = integer;
+ int i;
+ char *e;
+
+ /* Don't interpret the empty string as an integer. */
+ /* Currently does not worry about overflow or int/long differences. */
+ i = (int) strtol(v->u.s, &e, 10);
+ if ((v->u.s == e) || *e)
+ return 0;
+ free (v->u.s);
+ v->u.i = i;
+ v->type = integer;
}
return 1;
}