[PATCH 01/14] Cleanup: correctly handle upper bound of array

Dirk Hohndel dirk at hohndel.org
Thu Dec 28 16:35:29 PST 2017


Coverity CID 207684
Coverity CID 207724
Coverity CID 207728

Signed-off-by: Dirk Hohndel <dirk at hohndel.org>
---
 src/suunto_eonsteel_parser.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/suunto_eonsteel_parser.c b/src/suunto_eonsteel_parser.c
index 429e8626a9e4..7a64e5026c9c 100644
--- a/src/suunto_eonsteel_parser.c
+++ b/src/suunto_eonsteel_parser.c
@@ -217,7 +217,7 @@ static int fill_in_group_details(suunto_eonsteel_parser_t *eon, struct type_desc
 		long index;
 
 		index = strtol(grp, &end, 10);
-		if (index < 0 || index > MAXTYPE || end == grp) {
+		if (index < 0 || index >= MAXTYPE || end == grp) {
 			ERROR(eon->base.context, "Group type descriptor '%s' does not parse", desc->desc);
 			break;
 		}
@@ -344,7 +344,7 @@ static int record_type(suunto_eonsteel_parser_t *eon, unsigned short type, const
 		}
 	} while ((name = next) != NULL);
 
-	if (type > MAXTYPE) {
+	if (type >= MAXTYPE) {
 		ERROR(eon->base.context, "Type out of range (%04x: '%s' '%s' '%s')",
 			type,
 			desc.desc ? desc.desc : "",
@@ -413,7 +413,7 @@ static int traverse_entry(suunto_eonsteel_parser_t *eon, const unsigned char *p,
 			end += 4;
 		}
 
-		if (type > MAXTYPE || !eon->type_desc[type].desc) {
+		if (type >= MAXTYPE || !eon->type_desc[type].desc) {
 			HEXDUMP(eon->base.context, DC_LOGLEVEL_DEBUG, "last", last, 16);
 			HEXDUMP(eon->base.context, DC_LOGLEVEL_DEBUG, "this", begin, 16);
 		} else {
-- 
2.15.1



More information about the devel mailing list