Use ascii_strdown_inplace instead of g_ascii_strdown in a few places.

This also fixes a few cases where memory was not freed after
 g_ascii_strdown.

svn path=/trunk/; revision=27254
This commit is contained in:
Bill Meier 2009-01-17 17:33:50 +00:00
parent 0147b08a4e
commit c53d96ac3b
4 changed files with 28 additions and 27 deletions

View File

@ -43,6 +43,8 @@
#include <glib.h>
#include <wsutil/str_util.h>
#include <epan/packet.h>
#include <epan/conversation.h>
#include <epan/strutil.h>
@ -2261,11 +2263,7 @@ static int dissect_media( const gchar* fullmediatype, tvbuff_t * tvb, packet_inf
pinfo->match_string = ep_strdup(mediatype);
/* force to lower case */
{
gchar *mediatype_lowercase = g_ascii_strdown(mediatype, -1);
mediatype = ep_strdup(mediatype_lowercase);
g_free(mediatype_lowercase);
}
ascii_strdown_inplace(mediatype);
if (0 == strcmp("application/x-jxta-tls-block", mediatype)) {
/* If we recognize it as a TLS packet then we shuffle it off to ssl dissector. */

View File

@ -36,6 +36,9 @@
#include <ctype.h>
#include <glib.h>
#include <wsutil/str_util.h>
#include <epan/conversation.h>
#include <epan/strutil.h>
#include <epan/packet.h>
@ -485,8 +488,7 @@ dissect_msrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
gboolean have_body = FALSE;
gboolean found_match = FALSE;
gint content_type_len, content_type_parameter_str_len;
char *media_type_str = NULL;
char *media_type_str_lower_case = NULL;
gchar *media_type_str_lower_case = NULL;
char *content_type_parameter_str = NULL;
tvbuff_t *next_tvb;
gint parameter_offset;
@ -686,8 +688,8 @@ dissect_msrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
content_type_parameter_str = tvb_get_ephemeral_string(tvb,
parameter_offset, content_type_parameter_str_len);
}
media_type_str = tvb_get_ephemeral_string(tvb, value_offset, content_type_len);
media_type_str_lower_case = g_ascii_strdown(media_type_str, -1);
media_type_str_lower_case = ascii_strdown_inplace(
(gchar *)tvb_get_ephemeral_string(tvb, value_offset, content_type_len));
break;
default:
@ -720,7 +722,6 @@ dissect_msrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
media_type_str_lower_case,
next_tvb, pinfo,
msrp_data_tree);
g_free(media_type_str_lower_case);
pinfo->private_data = save_private_data;
/* If no match dump as text */
}

View File

@ -38,6 +38,9 @@
#include <epan/prefs.h>
#include <glib.h>
#include <wsutil/str_util.h>
#include <epan/packet.h>
#include <epan/req_resp_hdrs.h>
#include "packet-rtp.h"
@ -547,9 +550,8 @@ dissect_rtspmessage(tvbuff_t *tvb, int offset, packet_info *pinfo,
int value_offset;
int value_len;
e164_info_t e164_info;
gint rdt_feature_level = 0;
char *media_type_str_lower_case = NULL;
char *media_type_str = NULL;
gint rdt_feature_level = 0;
gchar *media_type_str_lower_case = NULL;
int semi_colon_offset;
int par_end_offset;
@ -889,10 +891,8 @@ dissect_rtspmessage(tvbuff_t *tvb, int offset, packet_info *pinfo,
value_len = par_end_offset - offset;
}
media_type_str = tvb_get_ephemeral_string(tvb, offset,
value_len);
media_type_str_lower_case = g_ascii_strdown(media_type_str, -1);
media_type_str_lower_case = ascii_strdown_inplace(
(gchar *)tvb_get_ephemeral_string(tvb, offset, value_len));
} else if (HDR_MATCHES(rtsp_content_length))
{

View File

@ -46,6 +46,9 @@
#include <epan/prefs.h>
#include <glib.h>
#include <wsutil/str_util.h>
#include <epan/packet.h>
#include <epan/req_resp_hdrs.h>
#include <epan/emem.h>
@ -1545,13 +1548,12 @@ dissect_sip_common(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tr
guchar cseq_number_set = 0;
char cseq_method[MAX_CSEQ_METHOD_SIZE] = "";
char call_id[MAX_CALL_ID_SIZE] = "";
char *media_type_str = NULL;
char *media_type_str_lower_case = NULL;
char *content_type_parameter_str = NULL;
guint resend_for_packet = 0;
guint request_for_response = 0;
gchar *media_type_str_lower_case = NULL;
char *content_type_parameter_str = NULL;
guint resend_for_packet = 0;
guint request_for_response = 0;
guint32 response_time = 0;
int strlen_to_copy;
int strlen_to_copy;
/*
@ -2231,12 +2233,12 @@ separator_found2:
content_type_parameter_str = tvb_get_ephemeral_string(tvb, parameter_offset,
content_type_parameter_str_len);
}
media_type_str = tvb_get_ephemeral_string(tvb, value_offset, content_type_len);
media_type_str_lower_case = g_ascii_strdown(media_type_str, -1);
media_type_str_lower_case = ascii_strdown_inplace(
(gchar *)tvb_get_ephemeral_string(tvb, value_offset, content_type_len));
/* Debug code
proto_tree_add_text(hdr_tree, tvb, value_offset,content_type_len,"media_type_str=%s",media_type_str);
proto_tree_add_text(hdr_tree, tvb, value_offset,content_type_len,
"media_type_str(lower cased)=%s",media_type_str_lower_case);
*/
break;