]> git.ipfire.org Git - thirdparty/util-linux.git/commit
lib: (strutils.c) fix unchecked lookahead in ul_parse_size()
authorChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Mon, 2 Feb 2026 00:15:41 +0000 (19:15 -0500)
committerChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Mon, 2 Feb 2026 00:36:18 +0000 (19:36 -0500)
commita9fbb9811ab1a147a0ff576f1534966031ffc0c4
tree431f3760d0ef6a16f2dfe3feec6a01cf71e52365
parent02ff631527f2e1a7b166c786e1900928a393d983
lib: (strutils.c) fix unchecked lookahead in ul_parse_size()

If the numeric value provided to ul_parse_size() via @str
is a decimal with fractions only containing zeros, the logic
fails to identify the end of the string and goes to the label
'check_suffix' and will do an unchecked lookahead (*p + 1)
that will result in an out-of-bounds read.

This is because the logic only checks for null-termination
when a fraction has been parsed, i.e. a fraction not only
containing zeros.

To fix the issue, we implicitly check for null-termination
when we have finished parsing the fraction.

Reported-by: Yashashree Gund <yash_gund@live.com>
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
lib/strutils.c