mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-30 18:41:11 +00:00
util/misc_util: Fix unchecked error
It's unlikely, but let's check for ftell() errors. BUG=b:64477774 BRANCH=none TEST=none Change-Id: I3690da60f756ab056e852e9f485b3c439c82e67b Signed-off-by: Patrick Georgi <pgeorgi@google.com> Found-by: Coverity Scan #58158 Reviewed-on: https://chromium-review.googlesource.com/719196 Commit-Ready: Patrick Georgi <pgeorgi@chromium.org> Tested-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-by: Martin Roth <martinroth@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
b6547eda9b
commit
87dbec5dfa
@@ -48,8 +48,11 @@ char *read_file(const char *filename, int *size)
|
||||
fseek(f, 0, SEEK_END);
|
||||
*size = ftell(f);
|
||||
rewind(f);
|
||||
if (*size > 0x100000) {
|
||||
fprintf(stderr, "File seems unreasonably large\n");
|
||||
if ((*size > 0x100000) || (*size < 0)) {
|
||||
if (*size < 0)
|
||||
perror("ftell failed");
|
||||
else
|
||||
fprintf(stderr, "File seems unreasonably large\n");
|
||||
fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user