From b99bf25795bee8d5e44affed8c02aa18e4bae2d7 Mon Sep 17 00:00:00 2001 From: Anders Broman Date: Wed, 19 Apr 2006 18:57:25 +0000 Subject: [PATCH] From Martin Mathieson: Fix coverity bugs. svn path=/trunk/; revision=17909 --- wiretap/catapult_dct2000.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/wiretap/catapult_dct2000.c b/wiretap/catapult_dct2000.c index 0bb50a3c33..69c0265d3e 100644 --- a/wiretap/catapult_dct2000.c +++ b/wiretap/catapult_dct2000.c @@ -840,6 +840,11 @@ gboolean parse_line(gint length, gint *seconds, gint *useconds, } protocol_name[protocol_chars] = linebuff[n]; } + if (protocol_chars == MAX_PROTOCOL_NAME) + { + /* If doesn't fit, fail rather than truncate */ + return FALSE; + } protocol_name[protocol_chars] = '\0'; /* Slash char must follow protocol name */ @@ -984,10 +989,17 @@ gboolean parse_line(gint length, gint *seconds, gint *useconds, { if (!isdigit(linebuff[n])) { + /* Found a non-digit before decimal point. Fail */ return FALSE; } seconds_buff[seconds_chars] = linebuff[n]; } + if (seconds_chars > MAX_SECONDS_CHARS) + { + /* Didn't fit in buffer. Fail rather than use truncated */ + return FALSE; + } + /* Convert found value into number */ seconds_buff[seconds_chars] = '\0'; *seconds = atoi(seconds_buff); @@ -1013,6 +1025,11 @@ gboolean parse_line(gint length, gint *seconds, gint *useconds, } subsecond_decimals_buff[subsecond_decimals_chars] = linebuff[n]; } + if (subsecond_decimals_chars > MAX_SUBSECOND_DECIMALS) + { + /* More numbers than expected - give up */ + return FALSE; + } /* Convert found value into microseconds */ subsecond_decimals_buff[subsecond_decimals_chars] = '\0'; *useconds = atoi(subsecond_decimals_buff) * 100;