mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-28 09:31:14 +00:00
modpost: avoid false-positive file open error
One problem of grab_file() is that it cannot distinguish the following two cases: - It cannot read the file (the file does not exist, or read permission is not set) - It can read the file, but the file size is zero This is because grab_file() calls mmap(), which requires the mapped length is greater than 0. Hence, grab_file() fails for both cases. If an empty header file were included for checksum calculation, the following warning would be printed: WARNING: modpost: could not open ...: Invalid argument An empty file is a valid source file, so it should not fail. Use read_text_file() instead. It can read a zero-length file. Then, parse_file() will succeed with doing nothing. Going forward, the first case (it cannot read the file) is a fatal error. If the source file from which an object was compiled is missing, something went wrong. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
This commit is contained in:
parent
f531c1b5de
commit
7c8f5662c5
1 changed files with 3 additions and 4 deletions
|
@ -258,9 +258,8 @@ static int parse_file(const char *fname, struct md4_ctx *md)
|
||||||
char *file;
|
char *file;
|
||||||
unsigned long i, len;
|
unsigned long i, len;
|
||||||
|
|
||||||
file = grab_file(fname, &len);
|
file = read_text_file(fname);
|
||||||
if (!file)
|
len = strlen(file);
|
||||||
return 0;
|
|
||||||
|
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
/* Collapse and ignore \ and CR. */
|
/* Collapse and ignore \ and CR. */
|
||||||
|
@ -287,7 +286,7 @@ static int parse_file(const char *fname, struct md4_ctx *md)
|
||||||
|
|
||||||
add_char(file[i], md);
|
add_char(file[i], md);
|
||||||
}
|
}
|
||||||
release_file(file, len);
|
free(file);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/* Check whether the file is a static library or not */
|
/* Check whether the file is a static library or not */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue