diff --git a/term-utils/agetty.c b/term-utils/agetty.c index a48998c16..3b3d5101a 100644 --- a/term-utils/agetty.c +++ b/term-utils/agetty.c @@ -2424,7 +2424,14 @@ static int caps_lock(char *s) static speed_t bcode(char *s) { const struct Speedtab *sp; - long speed = atol(s); + char *end = NULL; + long speed; + + errno = 0; + speed = strtol(s, &end, 10); + + if (errno || !end || end == s) + return 0; for (sp = speedtab; sp->speed; sp++) if (sp->speed == speed)