From: Tobias Stoeckmann Date: Wed, 21 Aug 2024 20:14:37 +0000 (+0200) Subject: libkmod: Treat illegal modinfo file as error X-Git-Tag: v34~492 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e9ace0b75a261411878ef78764f753eef068a735;p=thirdparty%2Fkmod.git libkmod: Treat illegal modinfo file as error 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 Reviewed-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/83 Signed-off-by: Lucas De Marchi --- diff --git a/libkmod/libkmod-builtin.c b/libkmod/libkmod-builtin.c index 48e2f752..88b0deb9 100644 --- a/libkmod/libkmod-builtin.c +++ b/libkmod/libkmod-builtin.c @@ -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; }