X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/79877e90f4799e15c2f2ab71ed2a935f244761c3..7c62bd3c1a9503acba49b01de46e218b59befbf5:/print-radius.c diff --git a/print-radius.c b/print-radius.c index acb88125..a8ec0db0 100644 --- a/print-radius.c +++ b/print-radius.c @@ -43,8 +43,8 @@ */ #ifndef lint -static const char rcsid[] = - "$Id: print-radius.c,v 1.15 2002-08-06 04:42:06 guy Exp $"; +static const char rcsid[] _U_ = + "$Id: print-radius.c,v 1.19.2.2 2003-11-16 08:51:40 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -319,7 +319,7 @@ static const char *prompt[]={ "No Echo", }; -struct attrtype { char *name; /* Attribute name */ +struct attrtype { const char *name; /* Attribute name */ const char **subtypes; /* Standard Values (if any) */ u_char siz_subtypes; /* Size of total standard values */ u_char first_subtype; /* First standard value is 0 or 1 */ @@ -519,12 +519,12 @@ print_attr_num(register u_char *data, u_int length, u_short attr_code ) { data_value = EXTRACT_32BITS(data); } - if ( data_value <= (attr_type[attr_code].siz_subtypes - 1 + + if ( data_value <= (u_int32_t)(attr_type[attr_code].siz_subtypes - 1 + attr_type[attr_code].first_subtype) && data_value >= attr_type[attr_code].first_subtype ) printf("{%s}",table[data_value]); else - printf("{#%d}",data_value); + printf("{#%u}",data_value); } else { @@ -646,7 +646,7 @@ print_attr_address(register u_char *data, u_int length, u_short attr_code ) /*************************************/ /* Returns nothing. */ /*************************************/ -static void print_attr_time(register u_char *data, u_int length, u_short attr_code) +static void print_attr_time(register u_char *data, u_int length, u_short attr_code _U_) { time_t attr_time; char string[26]; @@ -804,10 +804,17 @@ void radius_print(const u_char *dat, u_int length) { register const struct radius_hdr *rad; - register int i; - int len; + register u_int i; + u_int len; - i = min(length, snapend - dat); + if (snapend < dat) + { + printf(" [|radius]"); + return; + } + i = snapend - dat; + if (i > length) + i = length; if (i < MIN_RADIUS_LEN) { @@ -816,7 +823,7 @@ radius_print(const u_char *dat, u_int length) } rad = (struct radius_hdr *)dat; - len = ntohs(rad->len); + len = EXTRACT_16BITS(&rad->len); if (len < MIN_RADIUS_LEN) { @@ -832,46 +839,46 @@ radius_print(const u_char *dat, u_int length) switch (rad->code) { case RADCMD_ACCESS_REQ: - printf(" rad-access-req %d", length); + printf(" rad-access-req %u", length); break; case RADCMD_ACCESS_ACC: - printf(" rad-access-accept %d", length); + printf(" rad-access-accept %u", length); break; case RADCMD_ACCESS_REJ: - printf(" rad-access-reject %d", length); + printf(" rad-access-reject %u", length); break; case RADCMD_ACCOUN_REQ: - printf(" rad-account-req %d", length); + printf(" rad-account-req %u", length); break; case RADCMD_ACCOUN_RES: - printf(" rad-account-resp %d", length); + printf(" rad-account-resp %u", length); break; case RADCMD_ACCESS_CHA: - printf(" rad-access-cha %d", length); + printf(" rad-access-cha %u", length); break; case RADCMD_STATUS_SER: - printf(" rad-status-serv %d", length); + printf(" rad-status-serv %u", length); break; case RADCMD_STATUS_CLI: - printf(" rad-status-cli %d", length); + printf(" rad-status-cli %u", length); break; case RADCMD_RESERVED: - printf(" rad-reserved %d", length); + printf(" rad-reserved %u", length); break; default: - printf(" rad-#%d %d", rad->code, length); + printf(" rad-#%u %u", rad->code, length); break; } - printf(" [id %d]", rad->id); + printf(" [id %u]", rad->id); if (i) radius_attr_print( dat + MIN_RADIUS_LEN, i);