]> git.ipfire.org Git - thirdparty/grub.git/commit
lib/arg: Block repeated short options that require an argument
authorDaniel Axtens <dja@axtens.net>
Fri, 22 Jan 2021 05:07:29 +0000 (16:07 +1100)
committerDaniel Kiper <daniel.kiper@oracle.com>
Tue, 2 Mar 2021 14:54:17 +0000 (15:54 +0100)
commit2a330dba93ff11bc00eda76e9419bc52b0c7ead6
tree4e581107e7c6d67ae74c943a398126094564d58d
parentfe0586347ee46f927ae27bb9673532da9f5dead5
lib/arg: Block repeated short options that require an argument

Fuzzing found the following crash:

  search -hhhhhhhhhhhhhf

We didn't allocate enough option space for 13 hints because the
allocation code counts the number of discrete arguments (i.e. argc).
However, the shortopt parsing code will happily keep processing
a combination of short options without checking if those short
options require an argument. This means you can easily end writing
past the allocated option space.

This fixes a OOB write which can cause heap corruption.

Fixes: CVE-2021-20225
Reported-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/lib/arg.c