Skip to content

Commit 45bffae

Browse files
crassDaniel Kiper
authored and
Daniel Kiper
committed
util/resolve: Bail with error if moddep.lst file line is too long
The code reads each line into a buffer of size 1024 and does not check if the line is longer. So a line longer than 1024 will be read as a valid line followed by an invalid line. Then an error confusing to the user is sent with the test "invalid line format". But the line format is perfectly fine, the problem is in GRUB's parser. Check if we've hit a line longer than the size of the buffer, and if so send a more correct and reasonable error. Signed-off-by: Glenn Washburn <[email protected]> Reviewed-by: Daniel Kiper <[email protected]>
1 parent ddf47bd commit 45bffae

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Diff for: util/resolve.c

+3
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ read_dep_list (FILE *fp)
127127
mod->next = dep->list;
128128
dep->list = mod;
129129
}
130+
131+
if ((p - buf) == sizeof (buf))
132+
grub_util_error (_("line too long, length greater than %zu: module %s"), sizeof (buf), dep->name);
130133
}
131134

132135
return dep_list;

0 commit comments

Comments
 (0)