Stop depending on the order in which operations are performed by

generated code, as per Chris Foulds' note.

Also, when constructing the system ID or area string, always append the
four-octet groups, rather than overwriting them, as we had been doing.

svn path=/trunk/; revision=3414
This commit is contained in:
Guy Harris 2001-05-15 18:58:15 +00:00
parent dc710bd3df
commit 951f325eca
1 changed files with 11 additions and 7 deletions

View File

@ -2,7 +2,7 @@
* Routines for ISO/OSI network and transport protocol packet disassembly
* Main entrance point and common functions
*
* $Id: osi-utils.c,v 1.3 2001/04/16 10:04:33 guy Exp $
* $Id: osi-utils.c,v 1.4 2001/05/15 18:58:15 guy Exp $
* Laurent Deniel <deniel@worldnet.fr>
* Ralf Schneider <Ralf.Schneider@t-online.de>
*
@ -86,7 +86,7 @@ gchar *print_system_id( const guint8 *buffer, int length ) {
cur = str;
if ( ( 6 == length ) || ( 7 == length ) ) { /* Special case, print as MAC */
cur += sprintf(str, "%02x%02x.%02x%02x.%02x%02x", buffer[0], buffer[1],
cur += sprintf(cur, "%02x%02x.%02x%02x.%02x%02x", buffer[0], buffer[1],
buffer[2], buffer[3], buffer[4], buffer[5] );
if ( 7 == length ) {
sprintf( cur, "-%02x", buffer[6] );
@ -95,8 +95,10 @@ gchar *print_system_id( const guint8 *buffer, int length ) {
else {
tmp = 0;
while ( tmp < length / 4 ) { /* 16 / 4 == 4 > four Octets left to print */
cur += sprintf( str, "%02x%02x%02x%02x.", buffer[tmp++], buffer[tmp++],
buffer[tmp++], buffer[tmp++] );
cur += sprintf( cur, "%02x", buffer[tmp++] );
cur += sprintf( cur, "%02x", buffer[tmp++] );
cur += sprintf( cur, "%02x", buffer[tmp++] );
cur += sprintf( cur, "%02x.", buffer[tmp++] );
}
if ( 1 == tmp ) { /* Special case for Designated IS */
sprintf( --cur, "-%02x", buffer[tmp] );
@ -158,9 +160,11 @@ gchar *print_area(const guint8 *buffer, int length)
return( str );
}
if ( 4 < length ) {
while ( tmp < length / 4 ) { /* 16/4==4 four Octets left to print */
cur += sprintf( str, "%02x%02x%02x%02x.", buffer[tmp++], buffer[tmp++],
buffer[tmp++], buffer[tmp++] );
while ( tmp < length / 4 ) { /* 16/4==4 > four Octets left to print */
cur += sprintf( cur, "%02x", buffer[tmp++] );
cur += sprintf( cur, "%02x", buffer[tmp++] );
cur += sprintf( cur, "%02x", buffer[tmp++] );
cur += sprintf( cur, "%02x.", buffer[tmp++] );
}
if ( 1 == tmp ) { /* Special case for Designated IS */
sprintf( --cur, "-%02x", buffer[tmp] );