diff options
author | Pali Rohár <pali.rohar@gmail.com> | 2013-01-05 12:11:03 +0100 |
---|---|---|
committer | Pali Rohár <pali.rohar@gmail.com> | 2013-01-05 12:11:03 +0100 |
commit | e362f3cab9b58af81db4177104eacd806febf2c9 (patch) | |
tree | a3ee7a90f431cd8b384810d4ff46ea65171a7b38 /src | |
parent | 9ea9bea09681270de9922eddcbc111dcbdac077d (diff) | |
download | 0xFFFF-e362f3cab9b58af81db4177104eacd806febf2c9.tar.bz2 |
Fix crashing when accessing out of global arrays
Diffstat (limited to 'src')
-rw-r--r-- | src/device.c | 4 | ||||
-rw-r--r-- | src/image.c | 2 | ||||
-rw-r--r-- | src/main.c | 3 |
3 files changed, 4 insertions, 5 deletions
diff --git a/src/device.c b/src/device.c index 593e4b9..d4a80d7 100644 --- a/src/device.c +++ b/src/device.c @@ -51,7 +51,7 @@ enum device device_from_string(const char * device) { const char * device_to_string(enum device device) { - if ( device > sizeof(devices)/sizeof(devices[0]) ) + if ( device >= sizeof(devices)/sizeof(devices[0]) ) return NULL; return devices[device]; @@ -68,7 +68,7 @@ static const char * long_devices[] = { const char * device_to_long_string(enum device device) { - if ( device > sizeof(long_devices)/sizeof(long_devices[0]) ) + if ( device >= sizeof(long_devices)/sizeof(long_devices[0]) ) return NULL; return long_devices[device]; diff --git a/src/image.c b/src/image.c index 5f86e3b..994e3d0 100644 --- a/src/image.c +++ b/src/image.c @@ -540,7 +540,7 @@ enum image_type image_type_from_string(const char * type) { const char * image_type_to_string(enum image_type type) { - if ( type > sizeof(image_types)/sizeof(image_types[0]) ) + if ( type >= sizeof(image_types)/sizeof(image_types[0]) ) return NULL; return image_types[type]; @@ -300,7 +300,7 @@ static const char * image_tmp[] = { static const char * image_tmp_name(enum image_type type) { - if ( type > sizeof(image_tmp)/sizeof(image_tmp[0]) ) + if ( type >= sizeof(image_tmp)/sizeof(image_tmp[0]) ) return NULL; if ( ! image_tmp[type] || ! image_tmp[type][0] ) @@ -1288,7 +1288,6 @@ int main(int argc, char **argv) { } - } } |