From: Tobias Stoeckmann Date: Fri, 15 Nov 2024 17:45:28 +0000 (+0100) Subject: libkmod: Prevent ouf of boundary access X-Git-Tag: v34~59 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=213508a611bdf6e956ebb3af4107b92b377096c2;p=thirdparty%2Fkmod.git libkmod: Prevent ouf of boundary access Follow up of aad7c697, which fixes the same issue in another function. Signed-off-by: Tobias Stoeckmann Reviewed-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/248 Signed-off-by: Lucas De Marchi --- diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c index 07be771c..b989aa8b 100644 --- a/libkmod/libkmod-module.c +++ b/libkmod/libkmod-module.c @@ -1527,7 +1527,7 @@ KMOD_EXPORT long kmod_module_get_size(const struct kmod_module *mod) size = value; break; eat_line: - while (line[len - 1] != '\n' && fgets(line, sizeof(line), fp)) + while (len > 0 && line[len - 1] != '\n' && fgets(line, sizeof(line), fp)) len = strlen(line); } fclose(fp);