Skip to content

Commit

Permalink
libkmod: Prevent ouf of boundary access
Browse files Browse the repository at this point in the history
Do not access memory out of bounds if the first character read by fgets
is NUL. Treat such a character as EOL instead. This is a purely
defensive measure since /proc/modules should normaly not contain such
characters.

Signed-off-by: Tobias Stoeckmann <[email protected]>
  • Loading branch information
stoeckmann committed Nov 5, 2024
1 parent 093285c commit 98c6168
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libkmod/libkmod-module.c
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,7 @@ KMOD_EXPORT int kmod_module_new_from_loaded(struct kmod_ctx *ctx, struct kmod_li
kmod_module_unref(m);
}
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);
}

Expand Down

0 comments on commit 98c6168

Please sign in to comment.