]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
agetty: do not use atol()
authorKarel Zak <kzak@redhat.com>
Tue, 22 Jun 2021 15:26:11 +0000 (17:26 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 20 Jul 2021 09:50:52 +0000 (11:50 +0200)
Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
term-utils/agetty.c

index a48998c16bf71109510e0b8ba9d7991a45dc5cf3..3b3d5101adda3dd740ee499ad7ef72b3fd01dd6b 100644 (file)
@@ -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)