diff options
| author | Ludovic Rousseau <ludovic.rousseau+github@gmail.com> | 2013-10-06 14:23:20 +0200 |
|---|---|---|
| committer | Ludovic Rousseau <ludovic.rousseau+github@gmail.com> | 2013-10-06 14:26:25 +0200 |
| commit | 3d84bba0a7ff2d9e28f5aac43775f9a267caa4e8 (patch) | |
| tree | e2ba96cd602d56b413c4b64e6d509e9f51136e42 /examples/ezusb.c | |
| parent | a9cd54f24d566062a461d27f615365f41a3d11e8 (diff) | |
| download | platform_external_libusb-3d84bba0a7ff2d9e28f5aac43775f9a267caa4e8.tar.gz platform_external_libusb-3d84bba0a7ff2d9e28f5aac43775f9a267caa4e8.tar.bz2 platform_external_libusb-3d84bba0a7ff2d9e28f5aac43775f9a267caa4e8.zip | |
examples: check value returned by ftell()
Problem detected by the Coverity tool
CID 1042546 (#1 of 1): Argument cannot be negative (NEGATIVE_RETURNS)3.
negative_returns: "initial_pos" is passed to a parameter that cannot be
negative.
fseek(3) can't be called with a negative offset with SEEK_SET
Diffstat (limited to 'examples/ezusb.c')
| -rw-r--r-- | examples/ezusb.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/examples/ezusb.c b/examples/ezusb.c index 5699a10..278af5d 100644 --- a/examples/ezusb.c +++ b/examples/ezusb.c @@ -436,7 +436,11 @@ static int parse_iic(FILE *image, void *context, uint8_t block_header[4]; int rc; bool external = false; - long file_size, initial_pos = ftell(image); + long file_size, initial_pos; + + initial_pos = ftell(image); + if (initial_pos < 0) + return -1; fseek(image, 0L, SEEK_END); file_size = ftell(image); |
