Ethereal-dev: [Ethereal-dev] Bugs in osi_utils.c

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

From: "Chris Foulds" <Chris.Foulds@xxxxxxxxxxx>
Date: Tue, 15 May 2001 16:10:17 +0100

Hi,

I've just found a couple of bugs in osi_utils.c in the routines :

print_system_id
print_area

there is the line

cur += sprintf( str, "%02x%02x%02x%02x.", buffer[tmp++],
buffer[tmp++],buffer[tmp++], buffer[tmp++] );

This however does not work due to tmp++ being a post increment and occuring
AFTER the sprintf has
took place. This means you get the first byte replicated in the generated string
 all four times.
The simple fix I have made on ours for now is splitting it over four lines ,
thus

        cur += sprintf(str,"%02x",buffer[tmp++]);
        cur += sprintf(cur,"%02x",buffer[tmp++]);
        cur += sprintf(cur,"%02x",buffer[tmp++]);
        cur += sprintf(cur,"%02x",buffer[tmp++]);

This turned what was believed to be a bad trace into something alot more
readable.

Chris
-------------------------------------------------------------------
Chris Foulds
Software Engineer
Marconi , Technology Drive,
Beeston , Nottingham , NG9 1LA
Tel : +44 (0)115 9064118
Fax: +44 (0)115 9064242
Email : chris.foulds@xxxxxxxxxxx
-------------------------------------------------------------------