From c0617de5a4a888325d7ae9efe12a69fe46579549 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 22 Jun 2021 17:26:11 +0200 Subject: [PATCH] agetty: do not use atol() Addresses: https://github.com/karelzak/util-linux/issues/1358 Signed-off-by: Karel Zak --- term-utils/agetty.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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)