Ethereal-dev: Re: [Ethereal-dev] "Interesting" code in gtk/ansi_map_stat.c and gtk/isup_stat.c

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Sun, 21 Dec 2003 14:27:02 -0800
On Sun, Dec 21, 2003 at 02:04:52PM +0100, Joerg Mayer wrote:
> Compiling both files results in the following warning:
> 
> ansi_map_stat.c:102: warning: comparison is always false due to limited range of data type
> isup_stat.c:102: warning: comparison is always false due to limited range of data type
> 
>     if (data_p->message_type > sizeof(stat.message_type))
> 
> where data_p->message_type is guint8 and stat.message_type is int
> message_type[0xff] and thus 1020 is alwas greater than the contents
> of a guint8.

1020 is the wrong value - that array should have 256 elements, not 255,
if it's to be indexed by a 1-octet unsigned value that's not known to
have values in a smaller range than 0-255.

In addition, "sizeof(array)" isn't the number of elements in the array
unless the elements are one byte long.

I've checked changes to make the arrays the right size and to do the
right check against the number of elements in the array.