From: Karel Zak Date: Fri, 25 Jun 2021 08:24:35 +0000 (+0200) Subject: pg: do not use atoi() X-Git-Tag: v2.37.1~34 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=45f40a1ed88c216af224bb97369f336cb51536b3;p=thirdparty%2Futil-linux.git pg: do not use atoi() Addresses: https://github.com/karelzak/util-linux/issues/1358 Signed-off-by: Karel Zak --- diff --git a/text-utils/pg.c b/text-utils/pg.c index d50e2ba8a5..b309b4dcae 100644 --- a/text-utils/pg.c +++ b/text-utils/pg.c @@ -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;