diff options
author | Randall Spangler <rspangler@chromium.org> | 2016-09-02 12:25:27 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-09-14 13:05:02 -0700 |
commit | d8a9ede87c0a0b804ef17c60f3b2baac3498f6ae (patch) | |
tree | c88b1a975f5eccc27767cf2e53b224656eafe25f /host/lib/host_misc.c | |
parent | afa7350dccee079673831ef16a7c60a9a74ba77f (diff) | |
download | vboot-d8a9ede87c0a0b804ef17c60f3b2baac3498f6ae.tar.gz |
futility/host lib: Fix coverity warnings
Assorted minor code issues, which we should fix so any new errors stand
out more.
BUG=chromium:643769
BRANCH=none
TEST=make runtests
Change-Id: Ib37b45dea54bd506b519b0304300b8d192e34339
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/382319
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'host/lib/host_misc.c')
-rw-r--r-- | host/lib/host_misc.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/host/lib/host_misc.c b/host/lib/host_misc.c index 3fb9b24e..89a6c2f1 100644 --- a/host/lib/host_misc.c +++ b/host/lib/host_misc.c @@ -27,7 +27,7 @@ char* StrCopy(char* dest, const char* src, int dest_size) { uint8_t* ReadFile(const char* filename, uint64_t* sizeptr) { FILE* f; uint8_t* buf; - uint64_t size; + long size; f = fopen(filename, "rb"); if (!f) { @@ -37,6 +37,8 @@ uint8_t* ReadFile(const char* filename, uint64_t* sizeptr) { fseek(f, 0, SEEK_END); size = ftell(f); + if (size < 0) + return NULL; rewind(f); buf = malloc(size); |