]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod: Prevent ouf of boundary access
authorTobias Stoeckmann <tobias@stoeckmann.org>
Fri, 15 Nov 2024 17:45:28 +0000 (18:45 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Thu, 21 Nov 2024 04:34:33 +0000 (22:34 -0600)
Follow up of aad7c697, which fixes the same issue in another function.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/248
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
libkmod/libkmod-module.c

index 07be771c4569185a64c5e046a929b4b656c6f3a7..b989aa8b2238bd1c049c316d36a49576368176ec 100644 (file)
@@ -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);