Skip to content

Commit

Permalink
efi/libstub: prevent read overflow in find_file_option()
Browse files Browse the repository at this point in the history
[ Upstream commit c4039b2 ]

If the buffer has slashes up to the end then this will read past the end
of the array.  I don't anticipate that this is an issue for many people
in real life, but it's the right thing to do and it makes static
checkers happy.

Fixes: 7a88a62 ("efi/libstub: Fix path separator regression")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Dan Carpenter authored and gregkh committed Jun 10, 2021
1 parent 68e3441 commit e786eac
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/firmware/efi/libstub/file.c
Expand Up @@ -103,7 +103,7 @@ static int find_file_option(const efi_char16_t *cmdline, int cmdline_len,
return 0;

/* Skip any leading slashes */
while (cmdline[i] == L'/' || cmdline[i] == L'\\')
while (i < cmdline_len && (cmdline[i] == L'/' || cmdline[i] == L'\\'))
i++;

while (--result_len > 0 && i < cmdline_len) {
Expand Down

0 comments on commit e786eac

Please sign in to comment.