diff mbox series

[2/2] libkmod: fix possible double free with wrong modules.builtin.modinfo

Message ID 20210413112315.18907-3-sw0312.kim@samsung.com (mailing list archive)
State New, archived
Headers show
Series harden libkmod-builtin with wrong modules.builtin.modinfo | expand

Commit Message

Seung-Woo Kim April 13, 2021, 11:23 a.m. UTC
Fix double free for *modinfo with non '\0' terminated wrong
modules.builtin.modinfo, which is because EOF is minus value.

Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
---
 libkmod/libkmod-builtin.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libkmod/libkmod-builtin.c b/libkmod/libkmod-builtin.c
index a75a542f6942..a002cb5ee2c6 100644
--- a/libkmod/libkmod-builtin.c
+++ b/libkmod/libkmod-builtin.c
@@ -313,7 +313,7 @@  ssize_t kmod_builtin_get_modinfo(struct kmod_ctx *ctx, const char *modname,
 	while (offset < iter->next) {
 		offset = get_string(iter, pos, &line, &linesz);
 		if (offset <= 0) {
-			count = (offset) ? -errno : -EOF;
+			count = (offset) ? -errno : -EINVAL;
 			free(*modinfo);
 			goto fail;
 		}