diff options
author | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2007-11-27 18:52:51 +0000 |
---|---|---|
committer | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2007-11-27 18:52:51 +0000 |
commit | 4d005106f956ff792cd46cb90050f5ebf13f133e (patch) | |
tree | 593646c7e1eb44302243659672c5fc691f0d4272 /epan/dissectors/packet-afp.c | |
parent | 3a9435a5c8f4833aeebc0a120f4fd0657e25db3e (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.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@23623 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/dissectors/packet-afp.c')
-rw-r--r-- | epan/dissectors/packet-afp.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/epan/dissectors/packet-afp.c b/epan/dissectors/packet-afp.c index 149ce22a42..4b0ad27405 100644 --- a/epan/dissectors/packet-afp.c +++ b/epan/dissectors/packet-afp.c @@ -41,6 +41,10 @@ #include "packet-afp.h" +#ifdef NEED_G_ASCII_STRCASECMP_H +#include "g_ascii_strcasecmp.h" +#endif + /* The information in this module (AFP) comes from: AFP 2.1 & 2.2.pdf contained in AppleShare_IP_6.3_SDK @@ -2364,7 +2368,7 @@ decode_uam_parameters(const char *uam, int len_uam, tvbuff_t *tvb, proto_tree *t { int len; - if (!strncasecmp(uam, "Cleartxt passwrd", len_uam)) { + if (!g_ascii_strncasecmp(uam, "Cleartxt passwrd", len_uam)) { if ((offset & 1)) PAD(1); @@ -2372,7 +2376,7 @@ decode_uam_parameters(const char *uam, int len_uam, tvbuff_t *tvb, proto_tree *t proto_tree_add_item(tree, hf_afp_passwd, tvb, offset, len,FALSE); offset += len; } - else if (!strncasecmp(uam, "DHCAST128", len_uam)) { + else if (!g_ascii_strncasecmp(uam, "DHCAST128", len_uam)) { if ((offset & 1)) PAD(1); @@ -2380,7 +2384,7 @@ decode_uam_parameters(const char *uam, int len_uam, tvbuff_t *tvb, proto_tree *t proto_tree_add_item(tree, hf_afp_random, tvb, offset, len,FALSE); offset += len; } - else if (!strncasecmp(uam, "2-Way Randnum exchange", len_uam)) { + else if (!g_ascii_strncasecmp(uam, "2-Way Randnum exchange", len_uam)) { /* nothing */ return offset; } @@ -2403,7 +2407,7 @@ dissect_query_afp_login(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_tree_add_item(tree, hf_afp_UAM, tvb, offset, 1,FALSE); offset += len_uam +1; - if (!strncasecmp(uam, "No User Authent", len_uam)) { + if (!g_ascii_strncasecmp(uam, "No User Authent", len_uam)) { return offset; } |