From 8f3eb48bfb5e74d278a551745dcb43a4cb4d5be3 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Thu, 18 Apr 2013 08:11:51 +0200 Subject: [PATCH] Prevent an infinite loop. When the number of parameters is zero, there are no sample values, and the offset variable is never increased. The result is an infinite loop. In practice this shouldn't happen because there should always be at least one sample value (e.g. depth). But if a new data format is available, which is not yet supported by the parser, we might be trying to interpret the wrong byte. --- src/suunto_d9_parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/suunto_d9_parser.c b/src/suunto_d9_parser.c index 1334a3b..24de752 100644 --- a/src/suunto_d9_parser.c +++ b/src/suunto_d9_parser.c @@ -314,7 +314,7 @@ suunto_d9_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t ca // Number of parameters in the configuration data. unsigned int nparams = data[config]; - if (nparams > MAXPARAMS) + if (nparams == 0 || nparams > MAXPARAMS) return DC_STATUS_DATAFORMAT; // Available divisor values.