Skip to content

Commit d11164c

Browse files
authored
raster-interpret.c: Verify base for strtol()
Input for atoi() can be bad number for argument base in strtol(), causing returning an incorrect pointer address and later segfault. Break out from function if the base is incorrect. Fixes #1188
2 parents 745f21c + 7487b87 commit d11164c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

cups/raster-interpret.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,8 @@ scan_ps(_cups_ps_stack_t *st, /* I - Stack */
10411041
*cur, /* Current position */
10421042
*valptr, /* Pointer into value string */
10431043
*valend; /* End of value string */
1044-
int parens; /* Parenthesis nesting level */
1044+
int parens, /* Parenthesis nesting level */
1045+
base; /* Numeric base for strtol() */
10451046

10461047

10471048
if (!*ptr)
@@ -1302,7 +1303,16 @@ scan_ps(_cups_ps_stack_t *st, /* I - Stack */
13021303
* Integer with radix...
13031304
*/
13041305

1305-
obj.value.number = strtol(cur + 1, &cur, atoi(start));
1306+
base = atoi(start);
1307+
1308+
/*
1309+
* Postscript language reference manual dictates numbers from 2 to 36 as base...
1310+
*/
1311+
1312+
if (base < 2 || base > 36)
1313+
return (NULL);
1314+
1315+
obj.value.number = strtol(cur + 1, &cur, base);
13061316
break;
13071317
}
13081318
else if (strchr(".Ee()<>[]{}/%", *cur) || isspace(*cur & 255))

0 commit comments

Comments
 (0)