]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
more: Use ul_strtou16() in a robust way master
authorKarel Zak <kzak@redhat.com>
Tue, 1 Jul 2025 08:09:46 +0000 (10:09 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 1 Jul 2025 08:09:46 +0000 (10:09 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
text-utils/more.c

index 51c63e9245cda88bf65d1daa3b8ab687cb965051..4980aef4cac10063d8de02b927a488a9c4289a09 100644 (file)
@@ -2144,8 +2144,11 @@ int main(int argc, char **argv)
        if (getenv("MORESECURE") || getenv("PAGERSECURE"))
                ctl.is_secure = 1;
 
-       if ((s = getenv("MORE_SHELL_LINES")) && isdigit_string(s))
-               ul_strtou16(s, (uint16_t *) &ctl.lines_per_screen, 10);
+       if ((s = getenv("MORE_SHELL_LINES")) && isdigit_string(s)) {
+               uint16_t x = 0;
+               if (ul_strtou16(s, (uint16_t *) &x, 10) == 0)
+                       ctl.lines_per_screen = x;
+       }
 
        if ((s = getenv("MORE")) != NULL)
                env_argscan(&ctl, s);