Skip to content

Commit 951f8ef

Browse files
Dan Carpentergregkh
authored andcommitted
efi/libstub: prevent read overflow in find_file_option()
[ 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>
1 parent b828601 commit 951f8ef

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • drivers/firmware/efi/libstub

‎drivers/firmware/efi/libstub/file.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ static int find_file_option(const efi_char16_t *cmdline, int cmdline_len,
103103
return 0;
104104

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

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

0 commit comments

Comments
 (0)