mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-19 03:33:43 +03:00
pr: fix parsing of empty arguments
Before: $ pr --expand-tabs= pr: '-e' extra characters or invalid number in the argument: ‘SHELL=/bin/bash’: Value too large for defined data type After: $ pr --expand-tabs= pr: '-e': Invalid argument: ‘’ * src/pr.c (getoptarg): Ensure we don't parse beyond the end of an empty argument, thus outputting arbitrary stack info in subsequent error messages. Addresses https://bugs.debian.org/1035596
This commit is contained in:
1 parent
300af78691
commit
fae65623a9
1 file changed
+6
@@ -1168,6 +1168,12 @@ getoptnum (char const *n_str, int min, int *num, char const *err)
|
||||
static void
|
||||
getoptarg (char *arg, char switch_char, char *character, int *number)
|
||||
{
|
||||
if (!*arg)
|
||||
{
|
||||
error (0, 0, _("'-%c': Invalid argument: %s"), switch_char, quote (arg));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (!ISDIGIT (*arg))
|
||||
*character = *arg++;
|
||||
if (*arg)
|
||||
|
||||
Reference in new issue
Block a user