Skip to content

Commit

Permalink
boot: Fix OOB reads in conf/osrel parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
medhefgo committed Oct 15, 2023
1 parent f17670a commit 5ce851a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/boot/efi/efi-string.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ char *line_get_key_value(char *s, const char *sep, size_t *pos, char **ret_key,
line[linelen] = '\0';

/* remove leading whitespace */
while (strchr8(" \t", *line)) {
while (linelen > 0 && strchr8(" \t", *line)) {
line++;
linelen--;
}
Expand Down
2 changes: 2 additions & 0 deletions src/boot/efi/test-efi-string.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,9 @@ TEST(line_get_key_value) {
char *key, *value;

assert_se(!line_get_key_value((char[]){ "" }, "=", &pos, &key, &value));
assert_se(!line_get_key_value((char[]){ "\t" }, " \t", &pos, &key, &value));

pos = 0;
assert_se(line_get_key_value(s1, "=", &pos, &key, &value));
assert_se(streq8(key, "key"));
assert_se(streq8(value, "value"));
Expand Down

0 comments on commit 5ce851a

Please sign in to comment.