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 <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/227
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
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);
}