policycoreutils: semodule_package: do not fail with an empty fc file
When running sepolgen tests on a Linux 4.7 kernel, one test fails with the following message: /usr/bin/semodule_package: Failed to mmap tmp/module_compile_test.mod.fc: Invalid argument The .fc file is empty, which is why it cannot be used with mmap(). Anyway the current code supports empty files (with if() conditions in main()) so do not try to mmap an empty file in file_to_data(). Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
This commit is contained in:
parent
cb68b534e3
commit
266c16ff53
|
@ -72,6 +72,10 @@ static int file_to_data(const char *path, char **data, size_t * len)
|
|||
path, strerror(errno));
|
||||
goto err;
|
||||
}
|
||||
if (!sb.st_size) {
|
||||
*len = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
*data = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
if (*data == MAP_FAILED) {
|
||||
|
|
Loading…
Reference in New Issue