]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
pg: do not use atoi()
authorKarel Zak <kzak@redhat.com>
Fri, 25 Jun 2021 08:24:35 +0000 (10:24 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 20 Jul 2021 09:51:44 +0000 (11:51 +0200)
Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
text-utils/pg.c

index d50e2ba8a54e5e1557f8deacae70af8802ec5717..b309b4dcae4b05eb88f32458b3c50fbad7c5a334 100644 (file)
@@ -597,11 +597,8 @@ static int getcount(char *cmdstr)
        }
        if (buf[0] == '-' && buf[1] == '\0') {
                i = -1;
-       } else {
-               if (*buf == '+')
-                       i = atoi(buf + 1);
-               else
-                       i = atoi(buf);
+       } else if (ul_strtos32(*buf == '+' ? buf + 1 : buf, &i, 10) != 0) {
+               i = -1;
        }
        free(buf);
        return i;