]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod: Treat illegal modinfo file as error
authorTobias Stoeckmann <tobias@stoeckmann.org>
Wed, 21 Aug 2024 20:14:37 +0000 (22:14 +0200)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Thu, 22 Aug 2024 21:53:25 +0000 (16:53 -0500)
The file modules.builtin.modinfo is supposed to consist of NUL
terminated strings. If the file contains a string which is not
properly NUL terminated, treat it as error.

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/83
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
libkmod/libkmod-builtin.c

index 48e2f752dc20eb32367946db691af6e61115f628..88b0deb91c7b0acca2d00568b2a3624ea32d7ddf 100644 (file)
@@ -146,6 +146,10 @@ static off_t get_string(struct kmod_builtin_iter *iter, off_t offset,
        }
 
        if (linesz) {
+               if (iter->buf[linesz - 1] != '\0') {
+                       sv_errno = EINVAL;
+                       goto fail;
+               }
                *line = iter->buf;
                *size = linesz;
        }