check return value of malloc_read_fd

in case `malloc_read_fd` returns a negative error number, the result
would afterwards be casted to an unsigned size_t, and may have
theoretically caused an out-of-bounds memory access in the following
`strncmp` call.
This commit is contained in:
jsteemann 2018-10-05 01:29:19 +02:00 committed by Jason Evans
parent f80c97e477
commit 856319dc8a

View File

@ -567,6 +567,10 @@ init_thp_state(void) {
close(fd);
#endif
if (nread < 0) {
goto label_error;
}
if (strncmp(buf, sys_state_madvise, (size_t)nread) == 0) {
init_system_thp_mode = thp_mode_default;
} else if (strncmp(buf, sys_state_always, (size_t)nread) == 0) {