From: Glenn Washburn Date: Thu, 13 Jan 2022 02:55:01 +0000 (-0600) Subject: util/resolve: Bail with error if moddep.lst file line is too long X-Git-Tag: grub-2.12-rc1~496 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45bffae13;p=thirdparty%2Fgrub.git 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 Reviewed-by: Daniel Kiper --- diff --git a/util/resolve.c b/util/resolve.c index 5e9afa10c..b6e26312f 100644 --- a/util/resolve.c +++ b/util/resolve.c @@ -127,6 +127,9 @@ read_dep_list (FILE *fp) mod->next = dep->list; dep->list = mod; } + + if ((p - buf) == sizeof (buf)) + grub_util_error (_("line too long, length greater than %zu: module %s"), sizeof (buf), dep->name); } return dep_list;