diff options
Diffstat (limited to 'epan/dissectors')
30 files changed, 114 insertions, 209 deletions
diff --git a/epan/dissectors/packet-aprs.c b/epan/dissectors/packet-aprs.c index 60ce834462..eaee53a813 100644 --- a/epan/dissectors/packet-aprs.c +++ b/epan/dissectors/packet-aprs.c @@ -40,7 +40,6 @@ #include "config.h" #include <string.h> -#include <ctype.h> #include <math.h> #include <glib.h> @@ -515,7 +514,7 @@ dissect_aprs_msg( tvbuff_t *tvb, ch = tvb_get_guint8( tvb, offset ); - if ( isdigit( ch ) ) + if ( g_ascii_isdigit( ch ) ) { if ( wind ) proto_tree_add_item( msg_tree, *msg_items->hf_msg_dir, tvb, offset, 3, ENC_ASCII|ENC_NA ); @@ -900,7 +899,7 @@ dissect_aprs_weather( tvbuff_t *tvb, weather_tree = proto_item_add_subtree( tc, ett_aprs_weather_idx ); ch = tvb_get_guint8( tvb, offset ); - if ( isdigit( ch ) ) + if ( g_ascii_isdigit( ch ) ) { proto_tree_add_item( weather_tree, *weather_items->hf_weather_dir, tvb, offset, 3, ENC_ASCII|ENC_NA ); offset += 3; @@ -1019,7 +1018,7 @@ aprs_timestamp( proto_tree *aprs_tree, tvbuff_t *tvb, int offset ) tzone = "zulu"; ch= tvb_get_guint8( tvb, offset + 6 ); - if ( isdigit( ch ) ) + if ( g_ascii_isdigit( ch ) ) { /* MDHM */ proto_tree_add_item( aprs_tree, hf_aprs_mdhm, tvb, offset, data_len, ENC_ASCII|ENC_NA ); proto_tree_add_string( aprs_tree, hf_aprs_tz, tvb, offset, data_len, tzone ); @@ -1209,7 +1208,7 @@ aprs_position( proto_tree *aprs_tree, tvbuff_t *tvb, int offset, gboolean with_m gboolean probably_a_msg = FALSE; gboolean probably_not_a_msg = FALSE; - if ( isdigit( tvb_get_guint8( tvb, offset ) ) ) + if ( g_ascii_isdigit( tvb_get_guint8( tvb, offset ) ) ) { offset = aprs_default_string( aprs_tree, tvb, offset, 8, hf_aprs_lat ); symbol_table_id = tvb_get_guint8( tvb, offset ); diff --git a/epan/dissectors/packet-beep.c b/epan/dissectors/packet-beep.c index a57def696c..988accd062 100644 --- a/epan/dissectors/packet-beep.c +++ b/epan/dissectors/packet-beep.c @@ -29,7 +29,6 @@ #include "config.h" #include <stdio.h> -#include <ctype.h> #include <glib.h> #include <epan/packet.h> #include <epan/addr_resolv.h> @@ -256,7 +255,7 @@ static int num_len(tvbuff_t *tvb, int offset) { unsigned int i = 0; - while (isdigit(tvb_get_guint8(tvb, offset + i))) i++; + while (g_ascii_isdigit(tvb_get_guint8(tvb, offset + i))) i++; return i; diff --git a/epan/dissectors/packet-bthfp.c b/epan/dissectors/packet-bthfp.c index eb766e87aa..63cdf51c13 100644 --- a/epan/dissectors/packet-bthfp.c +++ b/epan/dissectors/packet-bthfp.c @@ -29,8 +29,6 @@ #include "config.h" -#include <ctype.h> - #include <epan/packet.h> #include <epan/prefs.h> #include <epan/expert.h> @@ -900,9 +898,9 @@ dissect_at_command(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, tvb_memcpy(tvb, at_stream, offset, length); at_stream[length] = '\0'; while (at_stream[i_char]) { - at_stream[i_char] = toupper(at_stream[i_char]); + at_stream[i_char] = g_ascii_toupper(at_stream[i_char]); if (!command_number) { - col_str[i_char] = toupper(col_str[i_char]); + col_str[i_char] = g_ascii_toupper(col_str[i_char]); if (!g_ascii_isgraph(col_str[i_char])) col_str[i_char] = ' '; } i_char += 1; diff --git a/epan/dissectors/packet-bthsp.c b/epan/dissectors/packet-bthsp.c index d7cbb86348..7469933039 100644 --- a/epan/dissectors/packet-bthsp.c +++ b/epan/dissectors/packet-bthsp.c @@ -24,8 +24,6 @@ #include "config.h" -#include <ctype.h> - #include <epan/packet.h> #include <epan/prefs.h> #include <epan/expert.h> @@ -315,9 +313,9 @@ dissect_at_command(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, tvb_memcpy(tvb, at_stream, offset, length); at_stream[length] = '\0'; while (at_stream[i_char]) { - at_stream[i_char] = toupper(at_stream[i_char]); + at_stream[i_char] = g_ascii_toupper(at_stream[i_char]); if (!command_number) { - col_str[i_char] = toupper(col_str[i_char]); + col_str[i_char] = g_ascii_toupper(col_str[i_char]); if (!g_ascii_isgraph(col_str[i_char])) col_str[i_char] = ' '; } i_char += 1; diff --git a/epan/dissectors/packet-catapult-dct2000.c b/epan/dissectors/packet-catapult-dct2000.c index 30c0d6df95..e947d589b4 100644 --- a/epan/dissectors/packet-catapult-dct2000.c +++ b/epan/dissectors/packet-catapult-dct2000.c @@ -26,7 +26,6 @@ #include <stdio.h> #include <stdlib.h> -#include <ctype.h> #include <epan/packet.h> #include <epan/conversation.h> @@ -1408,7 +1407,7 @@ static void parse_outhdr_string(const guchar *outhdr_string, gint outhdr_string_ /* Find digits */ for ( ; n < outhdr_string_len; n++) { - if (!isdigit(outhdr_string[n])) { + if (!g_ascii_isdigit(outhdr_string[n])) { break; } else { @@ -1922,8 +1921,8 @@ static void dissect_tty_lines(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre /* Extract & add the string. */ char *string = (char*)tvb_get_string_enc(wmem_packet_scope(), tvb, offset, linelen, ENC_ASCII); - if (isascii(string[0])) { - /* If looks printable treat as string... */ + if (g_ascii_isprint(string[0])) { + /* If the first byte of the string is printable ASCII treat as string... */ proto_tree_add_string_format(tty_tree, hf_catapult_dct2000_tty_line, tvb, offset, linelen, string, diff --git a/epan/dissectors/packet-cups.c b/epan/dissectors/packet-cups.c index 7f7f4b9607..5ad008e4d1 100644 --- a/epan/dissectors/packet-cups.c +++ b/epan/dissectors/packet-cups.c @@ -23,9 +23,8 @@ #include "config.h" -#include <ctype.h> - #include <glib.h> +#include <wsutil/str_util.h> #include <epan/packet.h> /**********************************************************************/ @@ -230,17 +229,8 @@ get_hex_uint(tvbuff_t *tvb, gint offset, gint *next_offset) int c; guint u = 0; - while (isxdigit(c = tvb_get_guint8(tvb, offset))) { - if (isdigit(c)) - c -= '0'; - else if (isupper(c)) - c -= 'A' - 10; - else if (islower(c)) - c -= 'a' - 10; - else - c = 0; /* This should not happen. */ - - u = 16*u + c; + while (g_ascii_isxdigit(c = tvb_get_guint8(tvb, offset))) { + u = 16*u + ws_xton(c); offset++; } diff --git a/epan/dissectors/packet-diameter.c b/epan/dissectors/packet-diameter.c index d09d620770..6f91180216 100644 --- a/epan/dissectors/packet-diameter.c +++ b/epan/dissectors/packet-diameter.c @@ -44,7 +44,6 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <ctype.h> #include <glib.h> @@ -1402,7 +1401,7 @@ alnumerize(char *name) char c; for (;(c = *r); r++) { - if (isalnum((unsigned char)c) || c == '_' || c == '-' || c == '.') { + if (g_ascii_isalnum(c) || c == '_' || c == '-' || c == '.') { *(w++) = c; } } diff --git a/epan/dissectors/packet-ftp.c b/epan/dissectors/packet-ftp.c index 2557457dc0..b153ad7bf3 100644 --- a/epan/dissectors/packet-ftp.c +++ b/epan/dissectors/packet-ftp.c @@ -28,7 +28,6 @@ #include <stdio.h> #include <stdlib.h> -#include <ctype.h> #include <string.h> #include <glib.h> @@ -218,7 +217,7 @@ parse_port_pasv(const guchar *line, int linelen, guint32 *ftp_ip, guint16 *ftp_p /* * Look for a digit. */ - while ((c = *p) != '\0' && !isdigit(c)) + while ((c = *p) != '\0' && !g_ascii_isdigit(c)) p++; if (*p == '\0') { @@ -255,7 +254,7 @@ parse_port_pasv(const guchar *line, int linelen, guint32 *ftp_ip, guint16 *ftp_p * Well, that didn't work. Skip the first number we found, * and keep trying. */ - while ((c = *p) != '\0' && isdigit(c)) + while ((c = *p) != '\0' && g_ascii_isdigit(c)) p++; } @@ -267,9 +266,9 @@ isvalid_rfc2428_delimiter(const guchar c) { /* RFC2428 sect. 2 states rules for a valid delimiter */ const gchar *forbidden = "0123456789abcdef.:"; - if (c < 33 || c > 126) + if (!g_ascii_isgraph(c)) return FALSE; - if (strchr(forbidden, tolower(c))) + if (strchr(forbidden, g_ascii_tolower(c))) return FALSE; return TRUE; } @@ -629,8 +628,8 @@ dissect_ftp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) * treat non-continuation lines not beginning with digits * as errors? */ - if (linelen >= 3 && isdigit(line[0]) && isdigit(line[1]) - && isdigit(line[2])) { + if (linelen >= 3 && g_ascii_isdigit(line[0]) && g_ascii_isdigit(line[1]) + && g_ascii_isdigit(line[2])) { /* * One-line reply, or first or last line * of a multi-line reply. diff --git a/epan/dissectors/packet-giop.c b/epan/dissectors/packet-giop.c index 8bfe8e0435..8bf96c9576 100644 --- a/epan/dissectors/packet-giop.c +++ b/epan/dissectors/packet-giop.c @@ -281,7 +281,6 @@ #include <string.h> #include <stdio.h> #include <errno.h> -#include <ctype.h> #include <glib.h> #include <math.h> @@ -297,6 +296,7 @@ #include "packet-ziop.h" #include "packet-tcp.h" #include <wsutil/file_util.h> +#include <wsutil/str_util.h> #include <wsutil/pint.h> void proto_register_giop(void); @@ -1404,38 +1404,6 @@ static void insert_in_objkey_hash(GHashTable *hash, const gchar *obj, guint32 le } - - -/* - * convert an ascii char representing a hex value, - * to a numeric value. - * - * returns value, or -1 if problem. - * - */ - -static gint8 hex_char_to_val(guchar c) { - gint8 retval; - - if (!isxdigit(c)) { - return -1; - } - if (isdigit(c)) { - retval = c - 48; /* convert digit */ - return retval; - } - - c = toupper(c); /* convert to uppercase */ - if (c >= 'A' && c <= 'F') { - retval = c - 55; - return retval; - } - else { - return -1; - } - -} - /* * Convert from stringified IOR of the kind IOR:af4f7e459f.... * to an IOR octet sequence. @@ -1460,14 +1428,14 @@ static guint32 string_to_IOR(guchar *in, guint32 in_len, guint8 **out) { /* skip past IOR: and convert character pairs to guint8 */ for (i=4; i<in_len-1; i+=2) { - if ( isxdigit(in[i]) && isxdigit(in[i+1]) ) { /* hex ? */ + if ( g_ascii_isxdigit(in[i]) && g_ascii_isxdigit(in[i+1]) ) { /* hex ? */ - if ( (tmpval_msb = hex_char_to_val(in[i])) < 0 ) { + if ( (tmpval_msb = ws_xton(in[i])) < 0 ) { g_warning("giop: Invalid value in IOR %i \n", tmpval_msb); } - if ( (tmpval_lsb = hex_char_to_val(in[i+1])) < 0 ) { + if ( (tmpval_lsb = ws_xton(in[i+1])) < 0 ) { g_warning("giop: Invalid value in IOR %i \n", tmpval_lsb); } diff --git a/epan/dissectors/packet-http.c b/epan/dissectors/packet-http.c index ebfba9e19e..897a88479d 100644 --- a/epan/dissectors/packet-http.c +++ b/epan/dissectors/packet-http.c @@ -32,7 +32,6 @@ #include <stdlib.h> #include <string.h> -#include <ctype.h> #include <errno.h> #include <glib.h> @@ -894,20 +893,14 @@ dissect_http_message(tvbuff_t *tvb, int offset, packet_info *pinfo, c = *linep++; /* - * This must be a CHAR to be part of a token; that - * means it must be ASCII. - */ - if (!isascii(c)) - break; /* not ASCII, thus not a CHAR */ - - /* - * This mustn't be a CTL to be part of a token. + * This must be a CHAR, and not a CTL, to be part + * of a token; that means it must be printable ASCII. * * XXX - what about leading LWS on continuation * lines of a header? */ - if (iscntrl(c)) - break; /* CTL, not part of a header */ + if (!g_ascii_isprint(c)) + break; /* not ASCII, thus not a CHAR, or a CTL */ /* * This mustn't be a SEP to be part of a token; @@ -2573,7 +2566,7 @@ process_header(tvbuff_t *tvb, int offset, int next_offset, if (eh_ptr->content_length < 0 || p == value || errno == ERANGE || - (*up != '\0' && !isspace(*up))) { + (*up != '\0' && !g_ascii_isspace(*up))) { /* * Content length not valid; pretend * we don't have it. diff --git a/epan/dissectors/packet-icap.c b/epan/dissectors/packet-icap.c index a0f1d238cf..71fa989c41 100644 --- a/epan/dissectors/packet-icap.c +++ b/epan/dissectors/packet-icap.c @@ -26,7 +26,6 @@ #include "config.h" #include <string.h> -#include <ctype.h> #include <glib.h> #include <epan/packet.h> @@ -142,23 +141,16 @@ dissect_icap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) c = *linep++; /* - * This must be a CHAR to be part of a token; that - * means it must be ASCII. - */ - if (!isascii(c)) { - is_icap = FALSE; - break; /* not ASCII, thus not a CHAR */ - } - - /* - * This mustn't be a CTL to be part of a token. + * This must be a CHAR, and must not be a CTL to be part + * of a token; that means it must be printable ASCII. * * XXX - what about leading LWS on continuation * lines of a header? */ - if (iscntrl(c)) { + if (!g_ascii_isprint(c)) { + /* not ASCII, thus not a CHAR, or not printabe, thus a CTL */ is_icap = FALSE; - break; /* CTL, not part of a header */ + break; /* not ASCII, thus not a CHAR, or a CTL */ } switch (c) { diff --git a/epan/dissectors/packet-imap.c b/epan/dissectors/packet-imap.c index eb09ef4167..596609cb9b 100644 --- a/epan/dissectors/packet-imap.c +++ b/epan/dissectors/packet-imap.c @@ -31,7 +31,6 @@ #include "packet-ssl.h" #include <stdio.h> -#include <ctype.h> void proto_register_imap(void); void proto_reg_handoff_imap(void); @@ -162,7 +161,7 @@ dissect_imap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) tokenlen = get_token_len(line, line + linelen, &next_token); if (tokenlen != 0) { for (iter = 0; iter < tokenlen && iter < MAX_BUFFER-1; iter++) { - tokenbuf[iter] = tolower(line[iter]); + tokenbuf[iter] = g_ascii_tolower(line[iter]); } if ( TRUE == is_request && strncmp(tokenbuf,"uid",tokenlen) == 0) { proto_tree_add_item(reqresp_tree, hf_imap_request_uid, tvb, offset, tokenlen, ENC_ASCII|ENC_NA); @@ -181,7 +180,7 @@ dissect_imap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) * Save command string to do specialized processing. */ for (iter = 0; iter < uid_tokenlen && iter < MAX_BUFFER-1; iter++) { - command_token[iter] = tolower(uid_line[iter]); + command_token[iter] = g_ascii_tolower(uid_line[iter]); } commandlen = uid_tokenlen; @@ -201,7 +200,7 @@ dissect_imap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) * Save command string to do specialized processing. */ for (iter = 0; iter < tokenlen && iter < 256; iter++) { - command_token[iter] = tolower(line[iter]); + command_token[iter] = g_ascii_tolower(line[iter]); } commandlen = tokenlen; diff --git a/epan/dissectors/packet-imf.c b/epan/dissectors/packet-imf.c index 882ce1c970..3cdf42cf19 100644 --- a/epan/dissectors/packet-imf.c +++ b/epan/dissectors/packet-imf.c @@ -24,8 +24,6 @@ #include "config.h" -#include <ctype.h> - #include <epan/packet.h> #include <epan/addr_resolv.h> #include <epan/prefs.h> @@ -364,7 +362,7 @@ dissect_imf_address(tvbuff_t *tvb, int offset, int length, proto_item *item, pac /* consume any whitespace */ for(addr_pos++ ;addr_pos < (offset + length); addr_pos++) { - if(!isspace(tvb_get_guint8(tvb, addr_pos))) { + if(!g_ascii_isspace(tvb_get_guint8(tvb, addr_pos))) { break; } } @@ -404,7 +402,7 @@ dissect_imf_mailbox(tvbuff_t *tvb, int offset, int length, proto_item *item, pac /* XXX: the '<' could be in the display name */ for(; offset < addr_pos; offset++) { - if(!isspace(tvb_get_guint8(tvb, offset))) { + if(!g_ascii_isspace(tvb_get_guint8(tvb, offset))) { break; } } @@ -518,7 +516,7 @@ dissect_imf_siolabel(tvbuff_t *tvb, int offset, int length, proto_item *item, pa end_offset = tvb_find_guint8(tvb, item_offset, length - (item_offset - offset), ';'); /* skip leading space */ - while (isspace(tvb_get_guint8(tvb, item_offset))) { + while (g_ascii_isspace(tvb_get_guint8(tvb, item_offset))) { item_offset++; } @@ -530,12 +528,12 @@ dissect_imf_siolabel(tvbuff_t *tvb, int offset, int length, proto_item *item, pa } value_offset = tvb_find_guint8(tvb, item_offset, length - (item_offset - offset), '=') + 1; - while (isspace(tvb_get_guint8(tvb, value_offset))) { + while (g_ascii_isspace(tvb_get_guint8(tvb, value_offset))) { value_offset++; } value_length = item_length - (value_offset - item_offset); - while (isspace(tvb_get_guint8(tvb, value_offset + value_length - 1))) { + while (g_ascii_isspace(tvb_get_guint8(tvb, value_offset + value_length - 1))) { value_length--; } @@ -600,7 +598,7 @@ dissect_imf_content_type(tvbuff_t *tvb, int offset, int length, proto_item *item /* first strip any whitespace */ for(i = 0; i < length; i++) { - if(!isspace(tvb_get_guint8(tvb, offset + i))) { + if(!g_ascii_isspace(tvb_get_guint8(tvb, offset + i))) { offset += i; break; } @@ -749,7 +747,7 @@ dissect_imf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* remove any leading whitespace */ for(value_offset = start_offset; value_offset < end_offset; value_offset++) - if(!isspace(tvb_get_guint8(tvb, value_offset))) { + if(!g_ascii_isspace(tvb_get_guint8(tvb, value_offset))) { break; } diff --git a/epan/dissectors/packet-irc.c b/epan/dissectors/packet-irc.c index 0cf85f939b..c2431ddfbf 100644 --- a/epan/dissectors/packet-irc.c +++ b/epan/dissectors/packet-irc.c @@ -41,7 +41,6 @@ #include "config.h" #include <glib.h> -#include <ctype.h> #include <epan/packet.h> #include <epan/expert.h> @@ -172,9 +171,9 @@ dissect_irc_request(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int off /* Warn if there is a "numeric" command */ if ((end_offset-offset == 3) && - (isdigit(tvb_get_guint8(tvb, offset))) && - (isdigit(tvb_get_guint8(tvb, offset+1))) && - (isdigit(tvb_get_guint8(tvb, offset+2)))) + (g_ascii_isdigit(tvb_get_guint8(tvb, offset))) && + (g_ascii_isdigit(tvb_get_guint8(tvb, offset+1))) && + (g_ascii_isdigit(tvb_get_guint8(tvb, offset+2)))) { expert_add_info(pinfo, request_item, &ei_irc_numeric_request_command); } @@ -187,9 +186,9 @@ dissect_irc_request(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int off /* Warn if there is a "numeric" command */ if ((eoc_offset-offset == 3) && - (isdigit(tvb_get_guint8(tvb, offset))) && - (isdigit(tvb_get_guint8(tvb, offset+1))) && - (isdigit(tvb_get_guint8(tvb, offset+2)))) + (g_ascii_isdigit(tvb_get_guint8(tvb, offset))) && + (g_ascii_isdigit(tvb_get_guint8(tvb, offset+1))) && + (g_ascii_isdigit(tvb_get_guint8(tvb, offset+2)))) { expert_add_info(pinfo, request_item, &ei_irc_numeric_request_command); } @@ -341,9 +340,9 @@ dissect_irc_response(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int of /* if response command is numeric, allow it to be filtered as an integer */ if ((end_offset-offset == 3) && - (isdigit(tvb_get_guint8(tvb, offset))) && - (isdigit(tvb_get_guint8(tvb, offset+1))) && - (isdigit(tvb_get_guint8(tvb, offset+2)))) + (g_ascii_isdigit(tvb_get_guint8(tvb, offset))) && + (g_ascii_isdigit(tvb_get_guint8(tvb, offset+1))) && + (g_ascii_isdigit(tvb_get_guint8(tvb, offset+2)))) { num_command = ((tvb_get_guint8(tvb, offset)-0x30)*100) + ((tvb_get_guint8(tvb, offset+1)-0x30)*10) + (tvb_get_guint8(tvb, offset+2)-0x30); hidden_item = proto_tree_add_uint(response_tree, hf_irc_response_num_command, tvb, offset, end_offset-offset, num_command); @@ -358,9 +357,9 @@ dissect_irc_response(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int of /* if response command is numeric, allow it to be filtered as an integer */ if ((eoc_offset-offset == 3) && - (isdigit(tvb_get_guint8(tvb, offset))) && - (isdigit(tvb_get_guint8(tvb, offset+1))) && - (isdigit(tvb_get_guint8(tvb, offset+2)))) + (g_ascii_isdigit(tvb_get_guint8(tvb, offset))) && + (g_ascii_isdigit(tvb_get_guint8(tvb, offset+1))) && + (g_ascii_isdigit(tvb_get_guint8(tvb, offset+2)))) { num_command = ((tvb_get_guint8(tvb, offset)-0x30)*100) + ((tvb_get_guint8(tvb, offset+1)-0x30)*10) + (tvb_get_guint8(tvb, offset+2)-0x30); hidden_item = proto_tree_add_uint(response_tree, hf_irc_response_num_command, tvb, offset, eoc_offset-offset, num_command); diff --git a/epan/dissectors/packet-megaco.c b/epan/dissectors/packet-megaco.c index 1097a0d240..ffc7e85d10 100644 --- a/epan/dissectors/packet-megaco.c +++ b/epan/dissectors/packet-megaco.c @@ -41,7 +41,6 @@ #include "config.h" #include <stdlib.h> -#include <ctype.h> #include <glib.h> @@ -433,7 +432,7 @@ dissect_megaco_text(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* assume at least one digit in version */ tvb_current_offset = tvb_previous_offset + 1; - if (isdigit(tvb_get_guint8(tvb, tvb_current_offset))) { + if (g_ascii_isdigit(tvb_get_guint8(tvb, tvb_current_offset))) { /* 2-digit version */ tvb_current_offset++; } @@ -525,7 +524,7 @@ dissect_megaco_text(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* Find token length */ for (tvb_offset=tvb_previous_offset; tvb_offset < tvb_len-1; tvb_offset++){ - if (!isalpha(tvb_get_guint8(tvb, tvb_offset ))){ + if (!g_ascii_isalpha(tvb_get_guint8(tvb, tvb_offset ))){ break; } } @@ -1489,7 +1488,7 @@ dissect_megaco_descriptors(tvbuff_t *tvb, proto_tree *megaco_tree_command_line, /* Find token length */ for (tvb_offset=tvb_previous_offset; tvb_offset < tvb_descriptors_end_offset -1; tvb_offset++){ - if (!isalpha(tvb_get_guint8(tvb, tvb_offset ))){ + if (!g_ascii_isalpha(tvb_get_guint8(tvb, tvb_offset ))){ break; } } @@ -1669,7 +1668,7 @@ dissect_megaco_mediadescriptor(tvbuff_t *tvb, proto_tree *megaco_tree_command_li /* Find token length */ for (tvb_next_offset=tvb_current_offset; tvb_next_offset < tvb_last_RBRKT; tvb_next_offset++){ - if (!isalpha(tvb_get_guint8(tvb, tvb_next_offset ))){ + if (!g_ascii_isalpha(tvb_get_guint8(tvb, tvb_next_offset ))){ break; } } @@ -2067,7 +2066,7 @@ dissect_megaco_signaldescriptor(tvbuff_t *tvb, packet_info *pinfo, proto_tree *m tvb_signals_end_offset = tvb_RBRKT; tvb_signals_start_offset = tvb_previous_offset; - if(toupper(tvb_get_guint8(tvb, tvb_previous_offset+1))=='G') + if(g_ascii_toupper(tvb_get_guint8(tvb, tvb_previous_offset+1))=='G') tokenlen = 2; /* token is compact text (SG) */ else tokenlen = 7; /* token must be verbose text (Signals) */ @@ -2366,7 +2365,7 @@ dissect_megaco_servicechangedescriptor(tvbuff_t *tvb, proto_tree *megaco_tree, tvb_previous_offset = megaco_tvb_skip_wsp(tvb, tvb_previous_offset); /* Find token length */ for (tvb_offset=tvb_previous_offset; tvb_offset < tvb_RBRKT; tvb_offset++){ - if (!isalpha(tvb_get_guint8(tvb, tvb_offset ))){ + if (!g_ascii_isalpha(tvb_get_guint8(tvb, tvb_offset ))){ break; } } @@ -3081,7 +3080,7 @@ dissect_megaco_LocalControldescriptor(tvbuff_t *tvb, proto_tree *megaco_mediades for (tvb_offset=tvb_current_offset; tvb_offset < tvb_next_offset; tvb_offset++){ guint8 octet; octet = tvb_get_guint8(tvb, tvb_offset); - if (!isalnum(octet)){ + if (!g_ascii_isalnum(octet)){ if ((octet!='/')&&(octet!='_')){ break; } diff --git a/epan/dissectors/packet-mgcp.c b/epan/dissectors/packet-mgcp.c index 4605da955e..a8522c843d 100644 --- a/epan/dissectors/packet-mgcp.c +++ b/epan/dissectors/packet-mgcp.c @@ -36,7 +36,6 @@ #include "config.h" #include <stdlib.h> -#include <ctype.h> #include <string.h> #include <epan/packet.h> @@ -661,7 +660,7 @@ static gboolean is_mgcp_rspcode(tvbuff_t *tvb, gint offset, gint maxlength) if (maxlength >= 3) { tvb_get_nstringz0(tvb, offset, sizeof(word), word); - if (isdigit(word[0]) && isdigit(word[1]) && isdigit(word[2])) + if (g_ascii_isdigit(word[0]) && g_ascii_isdigit(word[1]) && g_ascii_isdigit(word[2])) { returnvalue = TRUE; } @@ -800,7 +799,7 @@ static gint tvb_parse_param(tvbuff_t* tvb, gint offset, gint len, int** hf) for (counter = 1; ((len > (counter + tvb_current_offset-offset)) && (is_rfc2234_alpha(tempchar = tvb_get_guint8(tvb, tvb_current_offset+counter)) || - isdigit(tempchar))) ; + g_ascii_isdigit(tempchar))) ; counter++); if (tempchar == ':') diff --git a/epan/dissectors/packet-mrcpv2.c b/epan/dissectors/packet-mrcpv2.c index 75e859a6bf..03bd658d82 100644 --- a/epan/dissectors/packet-mrcpv2.c +++ b/epan/dissectors/packet-mrcpv2.c @@ -38,7 +38,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <ctype.h> #include <glib.h> @@ -502,7 +501,7 @@ dissect_mrcpv2_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) return -1; field4 = tvb_get_string_enc(wmem_packet_scope(), tvb, sp_start, sp_end - sp_start, ENC_ASCII); - if (isdigit(field3[0])) /* request ID is number, so it has to be response */ + if (g_ascii_isdigit(field3[0])) /* request ID is number, so it has to be response */ line_type = RESPONSE_LINE; else line_type = EVENT_LINE; diff --git a/epan/dissectors/packet-msrp.c b/epan/dissectors/packet-msrp.c index 12e8d6d040..368c5e5fb0 100644 --- a/epan/dissectors/packet-msrp.c +++ b/epan/dissectors/packet-msrp.c @@ -27,7 +27,6 @@ #include "config.h" #include <stdlib.h> -#include <ctype.h> #include <glib.h> @@ -516,9 +515,9 @@ dissect_msrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ */ is_msrp_response = FALSE; if (token_3_len == 3) { - if (isdigit(tvb_get_guint8(tvb, token_3_start)) && - isdigit(tvb_get_guint8(tvb, token_3_start + 1)) && - isdigit(tvb_get_guint8(tvb, token_3_start + 2))) { + if (g_ascii_isdigit(tvb_get_guint8(tvb, token_3_start)) && + g_ascii_isdigit(tvb_get_guint8(tvb, token_3_start + 1)) && + g_ascii_isdigit(tvb_get_guint8(tvb, token_3_start + 2))) { is_msrp_response = TRUE; } } diff --git a/epan/dissectors/packet-multipart.c b/epan/dissectors/packet-multipart.c index d664215dda..112a8e59c6 100644 --- a/epan/dissectors/packet-multipart.c +++ b/epan/dissectors/packet-multipart.c @@ -57,7 +57,6 @@ #include "config.h" #include <string.h> -#include <ctype.h> #include <glib.h> @@ -323,7 +322,7 @@ static char *find_parameter(char *parameters, const char *key, int *retlen) while (*p) { - while ((*p) && isspace((guchar)*p)) + while ((*p) && g_ascii_isspace(*p)) p++; /* Skip white space */ if (g_ascii_strncasecmp(p, key, keylen) == 0) @@ -363,7 +362,7 @@ static char *find_parameter(char *parameters, const char *key, int *retlen) */ p = start; while (*p) { - if (*p == ';' || isspace((guchar)*p)) + if (*p == ';' || g_ascii_isspace(*p)) break; p++; len++; diff --git a/epan/dissectors/packet-ntlmssp.c b/epan/dissectors/packet-ntlmssp.c index 9ad86796ce..8ad765edf4 100644 --- a/epan/dissectors/packet-ntlmssp.c +++ b/epan/dissectors/packet-ntlmssp.c @@ -29,7 +29,6 @@ #include <stdio.h> #endif #include <string.h> -#include <ctype.h> #include <glib.h> @@ -565,7 +564,7 @@ create_ntlmssp_v2_key(const char *nt_password _U_, const guint8 *serverchallenge str_to_unicode(ntlmssph->acct_name, buf); for (j = 0; j < (2*user_len); j++) { if (buf[j] != '\0') { - user_uppercase[j] = toupper(buf[j]); + user_uppercase[j] = g_ascii_toupper(buf[j]); } } } @@ -682,7 +681,7 @@ create_ntlmssp_v1_key(const char *nt_password, const guint8 *serverchallenge, co if (password_len > NTLMSSP_KEY_LEN) password_len = NTLMSSP_KEY_LEN; for (i = 0; i < password_len; i++) { - lm_password_upper[i] = toupper(nt_password[i]); + lm_password_upper[i] = g_ascii_toupper(nt_password[i]); } } else diff --git a/epan/dissectors/packet-pvfs2.c b/epan/dissectors/packet-pvfs2.c index 12c4afdda1..9aeecfa862 100644 --- a/epan/dissectors/packet-pvfs2.c +++ b/epan/dissectors/packet-pvfs2.c @@ -32,7 +32,6 @@ #include "config.h" #include <string.h> -#include <ctype.h> #include <glib.h> @@ -2404,7 +2403,7 @@ dissect_pvfs2_getconfig_response(tvbuff_t *tvb, proto_tree *parent_tree, tmp_entry_length = entry_length; /* Remove all whitespace from front of entry */ - while ((tmp_entry_length > 0) && (!isalnum(*tmp_entry)) && + while ((tmp_entry_length > 0) && (!g_ascii_isalnum(*tmp_entry)) && (*tmp_entry != '<')) { tmp_entry++; diff --git a/epan/dissectors/packet-rtpproxy.c b/epan/dissectors/packet-rtpproxy.c index f58163ae00..fa05af9f71 100644 --- a/epan/dissectors/packet-rtpproxy.c +++ b/epan/dissectors/packet-rtpproxy.c @@ -29,7 +29,6 @@ #include "config.h" #include <stdlib.h> -#include <ctype.h> #include <glib.h> #include <epan/address.h> @@ -517,7 +516,7 @@ dissect_rtpproxy(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data tvbuff_t *subtvb; /* If it does not start with a printable character it's not RTPProxy */ - if(!isprint(tvb_get_guint8(tvb, 0))) + if(!g_ascii_isprint(tvb_get_guint8(tvb, 0))) return 0; /* Extract Cookie */ diff --git a/epan/dissectors/packet-rtsp.c b/epan/dissectors/packet-rtsp.c index e67b86661e..3bbbc4abc2 100644 --- a/epan/dissectors/packet-rtsp.c +++ b/epan/dissectors/packet-rtsp.c @@ -31,7 +31,6 @@ #include <stdio.h> #include <stdlib.h> -#include <ctype.h> #include <glib.h> @@ -468,7 +467,7 @@ is_rtsp_request_or_reply(const guchar *line, size_t linelen, rtsp_type_t *type) size_t len = strlen(rtsp_methods[ii]); if (linelen >= len && g_ascii_strncasecmp(rtsp_methods[ii], line, len) == 0 && - (len == linelen || isspace(line[len]))) + (len == linelen || g_ascii_isspace(line[len]))) { *type = RTSP_REQUEST; rtsp_stat_info->request_method = @@ -516,7 +515,7 @@ rtsp_create_conversation(packet_info *pinfo, const guchar *line_begin, /* Get past "Transport:" and spaces */ tmp = buf + STRLEN_CONST(rtsp_transport); - while (*tmp && isspace(*tmp)) + while (*tmp && g_ascii_isspace(*tmp)) tmp++; /* Work out which transport type is here */ @@ -666,11 +665,11 @@ rtsp_get_content_length(const guchar *line_begin, size_t line_len) buf[line_len] = '\0'; tmp = buf + STRLEN_CONST(rtsp_content_length); - while (*tmp && isspace(*tmp)) + while (*tmp && g_ascii_isspace(*tmp)) tmp++; content_length = strtol(tmp, &p, 10); up = p; - if (up == tmp || (*up != '\0' && !isspace(*up))) + if (up == tmp || (*up != '\0' && !g_ascii_isspace(*up))) return -1; /* not a valid number */ return (int)content_length; } @@ -880,20 +879,14 @@ dissect_rtspmessage(tvbuff_t *tvb, int offset, packet_info *pinfo, c = *linep++; /* - * This must be a CHAR to be part of a token; that - * means it must be ASCII. - */ - if (!isascii(c)) - break; /* not ASCII, thus not a CHAR */ - - /* - * This mustn't be a CTL to be part of a token. + * This must be a CHAR, and not a CTL, to be part of a token; + * that means it must be printable ASCII. * * XXX - what about leading LWS on continuation * lines of a header? */ - if (iscntrl(c)) - break; /* CTL, not part of a header */ + if (!g_ascii_isprint(c)) + break; /* not ASCII, thus not a CHAR, or a CTL */ switch (c) { @@ -1273,7 +1266,7 @@ process_rtsp_request(tvbuff_t *tvb, int offset, const guchar *data, size_t len = strlen(rtsp_methods[ii]); if (linelen >= len && g_ascii_strncasecmp(rtsp_methods[ii], data, len) == 0 && - (len == linelen || isspace(data[len]))) + (len == linelen || g_ascii_isspace(data[len]))) break; } if (ii == RTSP_NMETHODS) { @@ -1299,15 +1292,15 @@ process_rtsp_request(tvbuff_t *tvb, int offset, const guchar *data, /* URL */ url = data; /* Skip method name again */ - while (url < lineend && !isspace(*url)) + while (url < lineend && !g_ascii_isspace(*url)) url++; /* Skip spaces */ - while (url < lineend && isspace(*url)) + while (url < lineend && g_ascii_isspace(*url)) url++; /* URL starts here */ url_start = url; /* Scan to end of URL */ - while (url < lineend && !isspace(*url)) + while (url < lineend && !g_ascii_isspace(*url)) url++; /* Create a URL-sized buffer and copy contents */ tmp_url = wmem_strndup(wmem_packet_scope(), url_start, url - url_start); @@ -1339,16 +1332,16 @@ process_rtsp_reply(tvbuff_t *tvb, int offset, const guchar *data, /* status code */ /* Skip protocol/version */ - while (status < lineend && !isspace(*status)) + while (status < lineend && !g_ascii_isspace(*status)) status++; /* Skip spaces */ - while (status < lineend && isspace(*status)) + while (status < lineend && g_ascii_isspace(*status)) status++; /* Actual code number now */ status_start = status; status_i = 0; - while (status < lineend && isdigit(*status)) + while (status < lineend && g_ascii_isdigit(*status)) status_i = status_i * 10 + *status++ - '0'; /* Add field to tree */ diff --git a/epan/dissectors/packet-sip.c b/epan/dissectors/packet-sip.c index d6848f3e0d..15826b7a52 100644 --- a/epan/dissectors/packet-sip.c +++ b/epan/dissectors/packet-sip.c @@ -33,8 +33,6 @@ #include "config.h" -#include <ctype.h> - #include <glib.h> #include <epan/packet.h> @@ -2244,7 +2242,7 @@ static void dissect_sip_via_header(tvbuff_t *tvb, proto_tree *tree, gint start_o { c = tvb_get_guint8(tvb, current_offset); - if (!isdigit(c)) + if (!g_ascii_isdigit(c)) { if (current_offset > port_offset) { @@ -2312,7 +2310,7 @@ static void dissect_sip_via_header(tvbuff_t *tvb, proto_tree *tree, gint start_o while (current_offset < line_end_offset) { c = tvb_get_guint8(tvb, current_offset); - if (!isalpha(c) && (c != '-')) + if (!g_ascii_isalpha(c) && (c != '-')) { break; } @@ -3047,7 +3045,7 @@ dissect_sip_common(tvbuff_t *tvb, int offset, int remaining_length, packet_info of method name */ for (sub_value_offset=0; sub_value_offset < value_len; sub_value_offset++) { - if (!isdigit((guchar)value[sub_value_offset])) + if (!g_ascii_isdigit(value[sub_value_offset])) { proto_tree_add_uint(cseq_tree, hf_sip_cseq_seq_no, tvb, value_offset, sub_value_offset, @@ -3058,7 +3056,7 @@ dissect_sip_common(tvbuff_t *tvb, int offset, int remaining_length, packet_info for (; sub_value_offset < value_len; sub_value_offset++) { - if (isalpha((guchar)value[sub_value_offset])) + if (g_ascii_isalpha(value[sub_value_offset])) { /* Have reached start of method name */ break; @@ -3120,7 +3118,7 @@ dissect_sip_common(tvbuff_t *tvb, int offset, int remaining_length, packet_info /* RSeq number */ for (sub_value_offset=0; sub_value_offset < value_len; sub_value_offset++) { - if (!isdigit((guchar)value[sub_value_offset])) + if (!g_ascii_isdigit(value[sub_value_offset])) { proto_tree_add_uint(rack_tree, hf_sip_rack_rseq_no, tvb, value_offset, sub_value_offset, @@ -3143,7 +3141,7 @@ dissect_sip_common(tvbuff_t *tvb, int offset, int remaining_length, packet_info /* CSeq number */ for ( ; sub_value_offset < value_len; sub_value_offset++) { - if (!isdigit((guchar)value[sub_value_offset])) + if (!g_ascii_isdigit(value[sub_value_offset])) { proto_tree_add_uint(rack_tree, hf_sip_rack_cseq_no, tvb, value_offset+cseq_no_offset, @@ -3156,7 +3154,7 @@ dissect_sip_common(tvbuff_t *tvb, int offset, int remaining_length, packet_info /* Get to start of CSeq method name */ for ( ; sub_value_offset < value_len; sub_value_offset++) { - if (isalpha((guchar)value[sub_value_offset])) + if (g_ascii_isalpha(value[sub_value_offset])) { /* Have reached start of method name */ break; @@ -4017,9 +4015,9 @@ sip_parse_line(tvbuff_t *tvb, int offset, gint linelen, guint *token_1_lenp) */ return OTHER_LINE; } - if (!isdigit(tvb_get_guint8(tvb, token_2_start)) || - !isdigit(tvb_get_guint8(tvb, token_2_start + 1)) || - !isdigit(tvb_get_guint8(tvb, token_2_start + 2))) { + if (!g_ascii_isdigit(tvb_get_guint8(tvb, token_2_start)) || + !g_ascii_isdigit(tvb_get_guint8(tvb, token_2_start + 1)) || + !g_ascii_isdigit(tvb_get_guint8(tvb, token_2_start + 2))) { /* * 3 characters yes, 3 digits no. */ diff --git a/epan/dissectors/packet-smb-pipe.c b/epan/dissectors/packet-smb-pipe.c index e34003ee07..e6762a8d80 100644 --- a/epan/dissectors/packet-smb-pipe.c +++ b/epan/dissectors/packet-smb-pipe.c @@ -34,7 +34,6 @@ XXX Fixme : shouldn't show [malformed frame] for long packets #include <time.h> #include <string.h> #include <glib.h> -#include <ctype.h> #include <epan/packet.h> #include <epan/exceptions.h> @@ -1596,12 +1595,12 @@ get_count(const guchar *desc, int *countp) int count = 0; guchar c; - if (!isdigit(*desc)) { + if (!g_ascii_isdigit(*desc)) { *countp = 1; /* no count was supplied */ return desc; } - while ((c = *desc) != '\0' && isdigit(c)) { + while ((c = *desc) != '\0' && g_ascii_isdigit(c)) { count = (count * 10) + c - '0'; desc++; } diff --git a/epan/dissectors/packet-smtp.c b/epan/dissectors/packet-smtp.c index af661a8504..9886de2135 100644 --- a/epan/dissectors/packet-smtp.c +++ b/epan/dissectors/packet-smtp.c @@ -28,7 +28,6 @@ #include "config.h" #include <stdlib.h> -#include <ctype.h> #include <glib.h> @@ -1023,8 +1022,8 @@ dissect_smtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) line_code[0] = tvb_get_guint8(tvb, offset); line_code[1] = tvb_get_guint8(tvb, offset+1); line_code[2] = tvb_get_guint8(tvb, offset+2); - if (isdigit(line_code[0]) && isdigit(line_code[1]) - && isdigit(line_code[2])) { + if (g_ascii_isdigit(line_code[0]) && g_ascii_isdigit(line_code[1]) + && g_ascii_isdigit(line_code[2])) { /* * We have a 3-digit response code. */ diff --git a/epan/dissectors/packet-spdy.c b/epan/dissectors/packet-spdy.c index fae1067432..cc0572f13d 100644 --- a/epan/dissectors/packet-spdy.c +++ b/epan/dissectors/packet-spdy.c @@ -34,8 +34,6 @@ #include "config.h" -#include <ctype.h> - #include <glib.h> #include <epan/conversation.h> #include <epan/packet.h> @@ -1057,8 +1055,8 @@ static spdy_header_info_t* spdy_find_saved_header_block(packet_info *pinfo _U_, static gchar* spdy_parse_content_type(gchar *content_type) { gchar *cp = content_type; - while (*cp != '\0' && *cp != ';' && !isspace(*cp)) { - *cp = tolower(*cp); + while (*cp != '\0' && *cp != ';' && !g_ascii_isspace(*cp)) { + *cp = g_ascii_tolower(*cp); ++cp; } if (*cp == '\0') { @@ -1067,7 +1065,7 @@ static gchar* spdy_parse_content_type(gchar *content_type) { if (cp != NULL) { *cp++ = '\0'; - while (*cp == ';' || isspace(*cp)) { + while (*cp == ';' || g_ascii_isspace(*cp)) { ++cp; } if (*cp != '\0') { diff --git a/epan/dissectors/packet-syslog.c b/epan/dissectors/packet-syslog.c index f03e3a6a4a..c9bc3c2ee4 100644 --- a/epan/dissectors/packet-syslog.c +++ b/epan/dissectors/packet-syslog.c @@ -29,7 +29,6 @@ #include "config.h" #include <string.h> -#include <ctype.h> #include <glib.h> @@ -246,7 +245,7 @@ dissect_syslog(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) msg_off++; pri = 0; while (tvb_bytes_exist(tvb, msg_off, 1) && - isdigit(tvb_get_guint8(tvb, msg_off)) && msg_off <= MAX_DIGITS) { + g_ascii_isdigit(tvb_get_guint8(tvb, msg_off)) && msg_off <= MAX_DIGITS) { pri = pri * 10 + (tvb_get_guint8(tvb, msg_off) - '0'); msg_off++; } diff --git a/epan/dissectors/packet-tpkt.c b/epan/dissectors/packet-tpkt.c index fe4900ebbb..4ba011ba9e 100644 --- a/epan/dissectors/packet-tpkt.c +++ b/epan/dissectors/packet-tpkt.c @@ -28,8 +28,6 @@ #include "config.h" -#include <ctype.h> - #include <glib.h> #include <epan/packet.h> @@ -124,11 +122,11 @@ is_asciitpkt(tvbuff_t *tvb) return -1; /* there aren't */ /* - * The first four octets should be ASCII + * The first four octets should be alphanumeric ASCII */ for (count = 0; count <=7 ; count ++) { - if(!isalnum(tvb_get_guint8(tvb,count))) + if(!g_ascii_isalnum(tvb_get_guint8(tvb,count))) { return 0; } diff --git a/epan/dissectors/packet-xcsl.c b/epan/dissectors/packet-xcsl.c index b5bbc3cf0b..5a549de9b0 100644 --- a/epan/dissectors/packet-xcsl.c +++ b/epan/dissectors/packet-xcsl.c @@ -29,7 +29,6 @@ #include <stdlib.h> #include <string.h> -#include <ctype.h> #include <glib.h> @@ -233,7 +232,7 @@ static void dissect_xcsl_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree /* This should be the transaction ID, if non-digit, it is treated as info */ case 1: - if ( isdigit(str[0]) ) { + if ( g_ascii_isdigit(str[0]) ) { proto_tree_add_item(xcsl_tree, &hfi_xcsl_transaction_id, tvb, offset, len, ENC_ASCII|ENC_NA); } else { proto_tree_add_item(xcsl_tree, &hfi_xcsl_information, tvb, offset, len, ENC_ASCII|ENC_NA); @@ -243,7 +242,7 @@ static void dissect_xcsl_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree /* Starting with non-digit -> Command, if it starts with a digit -> reply */ case 2: - if ( isdigit(str[0]) ) { + if ( g_ascii_isdigit(str[0]) ) { proto_item *xcsl_item; request = FALSE; |