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 /airpcap_loader.c | |
parent | a189f34b84345d6851a489c484c01c1bf21f56d1 (diff) | |
download | wireshark-9c89cdaaa3eccfe74d4e17705f38508c640b5047.tar.gz wireshark-9c89cdaaa3eccfe74d4e17705f38508c640b5047.tar.bz2 wireshark-9c89cdaaa3eccfe74d4e17705f38508c640b5047.zip |
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 'airpcap_loader.c')
-rw-r--r-- | airpcap_loader.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/airpcap_loader.c b/airpcap_loader.c index cad8500c73..411df70c8e 100644 --- a/airpcap_loader.c +++ b/airpcap_loader.c @@ -54,6 +54,10 @@ #include <airpcap.h> #include "airpcap_loader.h" +#ifdef NEED_G_ASCII_STRCASECMP_H +#include "g_ascii_strcasecmp.h" +#endif + /* * We load dynamically the dag library in order link it only when * it's present on the system @@ -153,7 +157,7 @@ get_wep_key(pref_t *pref, gpointer ud _U_) /* Retrieve user data info */ user_data = (keys_cb_data_t*)ud; - if (g_strncasecmp(pref->name, "wep_key", 7) == 0 && pref->type == PREF_STRING) + if (g_ascii_strncasecmp(pref->name, "wep_key", 7) == 0 && pref->type == PREF_STRING) { my_string = g_strdup(*pref->varp.string); @@ -219,7 +223,7 @@ set_wep_key(pref_t *pref, gpointer ud _U_) /* Retrieve user data info */ user_data = (keys_cb_data_t*)ud; - if (g_strncasecmp(pref->name, "wep_key", 7) == 0 && pref->type == PREF_STRING) + if (g_ascii_strncasecmp(pref->name, "wep_key", 7) == 0 && pref->type == PREF_STRING) { /* Ok, the pref we're gonna set is a wep_key ... but what number? */ sscanf(pref->name,"wep_key%d",&wep_key_number); @@ -1550,7 +1554,7 @@ airpcap_get_if_string_number(airpcap_if_info_t* if_info) */ if(a == 0) { - if(g_strcasecmp(if_info->name,AIRPCAP_DEVICE_ANY_EXTRACT_STRING)!=0) + if(g_ascii_strcasecmp(if_info->name,AIRPCAP_DEVICE_ANY_EXTRACT_STRING)!=0) number = g_strdup_printf("??"); else number = g_strdup_printf(AIRPCAP_CHANNEL_ANY_NAME); @@ -2238,7 +2242,7 @@ test_if_on(pref_t *pref, gpointer ud _U_) is_on = (gboolean*)ud; - if (g_strncasecmp(pref->name, "enable_decryption", 17) == 0 && pref->type == PREF_BOOL) + if (g_ascii_strncasecmp(pref->name, "enable_decryption", 17) == 0 && pref->type == PREF_BOOL) { number = *pref->varp.boolp; @@ -2335,7 +2339,7 @@ set_on_off(pref_t *pref, gpointer ud _U_) /* Retrieve user data info */ is_on = (gboolean*)ud; - if (g_strncasecmp(pref->name, "enable_decryption", 17) == 0 && pref->type == PREF_BOOL) + if (g_ascii_strncasecmp(pref->name, "enable_decryption", 17) == 0 && pref->type == PREF_BOOL) { number = *pref->varp.boolp; |