summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Rousseau <ludovic.rousseau+github@gmail.com>2013-10-06 14:23:20 +0200
committerLudovic Rousseau <ludovic.rousseau+github@gmail.com>2013-10-06 14:26:25 +0200
commit3d84bba0a7ff2d9e28f5aac43775f9a267caa4e8 (patch)
treee2ba96cd602d56b413c4b64e6d509e9f51136e42
parenta9cd54f24d566062a461d27f615365f41a3d11e8 (diff)
downloadlibusb-3d84bba0a7ff2d9e28f5aac43775f9a267caa4e8.tar.gz
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
-rw-r--r--examples/ezusb.c6
-rw-r--r--libusb/version_nano.h2
2 files changed, 6 insertions, 2 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);
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index d3d70cf..f919a2f 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 10845
+#define LIBUSB_NANO 10846