diff options
author | Guy Harris <guy@alum.mit.edu> | 2007-11-27 18:52:51 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2007-11-27 18:52:51 +0000 |
commit | 9c89cdaaa3eccfe74d4e17705f38508c640b5047 (patch) | |
tree | 593646c7e1eb44302243659672c5fc691f0d4272 /epan/dissectors/packet-multipart.c | |
parent | a189f34b84345d6851a489c484c01c1bf21f56d1 (diff) |
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
Diffstat (limited to 'epan/dissectors/packet-multipart.c')
-rw-r--r-- | epan/dissectors/packet-multipart.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/epan/dissectors/packet-multipart.c b/epan/dissectors/packet-multipart.c index fe2ceb393c..bbfcccd55f 100644 --- a/epan/dissectors/packet-multipart.c +++ b/epan/dissectors/packet-multipart.c @@ -73,6 +73,10 @@ #include "packet-imf.h" +#ifdef NEED_G_ASCII_STRCASECMP_H +#include "g_ascii_strcasecmp.h" +#endif + /* Dissector table for media requiring special attention in multipart * encapsulation. */ static dissector_table_t multipart_media_subdissector_table; @@ -338,7 +342,7 @@ static char *find_parameter(char *parameters, const char *key, int *retlen) while ((*p) && isspace((guchar)*p)) p++; /* Skip white space */ - if (strncasecmp(p, key, keylen) == 0) + if (g_ascii_strncasecmp(p, key, keylen) == 0) break; /* Skip to next parameter */ p = strchr(p, ';'); @@ -757,7 +761,7 @@ process_body_part(proto_tree *tree, tvbuff_t *tvb, const guint8 *boundary, if(content_encoding_str && remove_base64_encoding) { - if(!strncasecmp(content_encoding_str, "base64", 6)) + if(!g_ascii_strncasecmp(content_encoding_str, "base64", 6)) tmp_tvb = base64_decode(pinfo, tmp_tvb, filename ? filename : (typename ? typename : content_type_str)); } @@ -915,11 +919,11 @@ is_known_multipart_header(const char *header_str, guint len) for (i = 1; i < array_length(multipart_headers); i++) { if (len == strlen(multipart_headers[i].name) && - strncasecmp(header_str, multipart_headers[i].name, len) == 0) + g_ascii_strncasecmp(header_str, multipart_headers[i].name, len) == 0) return i; if (multipart_headers[i].compact_name != NULL && len == strlen(multipart_headers[i].compact_name) && - strncasecmp(header_str, multipart_headers[i].compact_name, len) == 0) + g_ascii_strncasecmp(header_str, multipart_headers[i].compact_name, len) == 0) return i; } |