diff options
author | Guy Harris <guy@alum.mit.edu> | 2004-03-20 19:09:22 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2004-03-20 19:09:22 +0000 |
commit | b1713c14a59d4a09b42ebb8196fc4cc72638a5cc (patch) | |
tree | 94bc05301f783d85cd4b623065d2586e2685acd8 /packet-radius.c | |
parent | 69f4254b00e1c4f3b6aad0e41436e99271007001 (diff) | |
download | wireshark-b1713c14a59d4a09b42ebb8196fc4cc72638a5cc.tar.gz wireshark-b1713c14a59d4a09b42ebb8196fc4cc72638a5cc.tar.bz2 wireshark-b1713c14a59d4a09b42ebb8196fc4cc72638a5cc.zip |
If we can't decrypt the user password, display it as hex data, not as
text.
Make "rdconvertbufftostr()" use "isprint()" to determine whether to
display a character as itself or as an escape. Move our redefinition of
"isprint()" above "rdconvertbufftostr()" so that we make the "is it
printable?" decision appropriately.
svn path=/trunk/; revision=10423
Diffstat (limited to 'packet-radius.c')
-rw-r--r-- | packet-radius.c | 79 |
1 files changed, 39 insertions, 40 deletions
diff --git a/packet-radius.c b/packet-radius.c index e2c10f6705..19274a7d05 100644 --- a/packet-radius.c +++ b/packet-radius.c @@ -6,7 +6,7 @@ * * RFC 2865, RFC 2866, RFC 2867, RFC 2868, RFC 2869 * - * $Id: packet-radius.c,v 1.98 2004/03/20 18:51:08 guy Exp $ + * $Id: packet-radius.c,v 1.99 2004/03/20 19:09:22 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -2246,6 +2246,23 @@ find_radius_attr_info(guint32 attr_type, const radius_attr_info *table) return(NULL); } +#if GLIB_MAJOR_VERSION >= 2 +/* + * XXX - "isprint()" can return "true" for non-ASCII characters, but + * those don't work with GTK+ 1.3 or later, as they take UTF-8 strings + * as input. Until we fix up Ethereal to properly handle non-ASCII + * characters in all output (both GUI displays and text printouts) + * in those versions of GTK+, we work around the problem by escaping + * all characters that aren't printable ASCII. + * + * We don't know what version of GTK+ we're using, as dissectors don't + * use any GTK+ stuff; we use GLib as a proxy for that, with GLib 2.x + * implying GTK+ 1.3 or later (we don't support GLib 1.3[.x]). + */ +#undef isprint +#define isprint(c) (c >= 0x20 && c < 0x7f) +#endif + static void rdconvertbufftostr(gchar *dest, tvbuff_t *tvb, int offset, int length) { @@ -2259,8 +2276,7 @@ rdconvertbufftostr(gchar *dest, tvbuff_t *tvb, int offset, int length) totlen=1; for (i=0; i < (guint32)length; i++) { - if( isalnum((int)pd[i])||ispunct((int)pd[i]) - ||((int)pd[i]==' ')) { + if( isprint((int)pd[i])) { dest[totlen]=(gchar)pd[i]; totlen++; } @@ -2274,22 +2290,25 @@ rdconvertbufftostr(gchar *dest, tvbuff_t *tvb, int offset, int length) dest[totlen+1]=0; } -#if GLIB_MAJOR_VERSION >= 2 -/* - * XXX - "isprint()" can return "true" for non-ASCII characters, but - * those don't work with GTK+ 1.3 or later, as they take UTF-8 strings - * as input. Until we fix up Ethereal to properly handle non-ASCII - * characters in all output (both GUI displays and text printouts) - * in those versions of GTK+, we work around the problem by escaping - * all characters that aren't printable ASCII. - * - * We don't know what version of GTK+ we're using, as dissectors don't - * use any GTK+ stuff; we use GLib as a proxy for that, with GLib 2.x - * implying GTK+ 1.3 or later (we don't support GLib 1.3[.x]). - */ -#undef isprint -#define isprint(c) (c >= 0x20 && c < 0x7f) -#endif +static void +rdconvertbufftobinstr(gchar *dest, tvbuff_t *tvb, int offset, int length) +{ +/*converts the raw buffer into printable hex display */ + guint32 i; + guint32 totlen=0; + const guint8 *pd = tvb_get_ptr(tvb, offset, length); + static const char hex[16] = { '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; + + for (i=0; i < (guint32)length; i++) + { + dest[totlen] = hex[pd[i] >> 4]; + totlen++; + dest[totlen] = hex[pd[i] & 0xF]; + totlen++; + } + dest[totlen]='\0'; +} static void rddecryptpass(gchar *dest,tvbuff_t *tvb,int offset,int length) @@ -2302,7 +2321,7 @@ rddecryptpass(gchar *dest,tvbuff_t *tvb,int offset,int length) guchar c; if (shared_secret[0] == '\0' || !authenticator ) { - rdconvertbufftostr(dest,tvb,offset,length); + rdconvertbufftobinstr(dest,tvb,offset,length); return; } @@ -2340,26 +2359,6 @@ rddecryptpass(gchar *dest,tvbuff_t *tvb,int offset,int length) dest[totlen+1] = '\0'; } -static void -rdconvertbufftobinstr(gchar *dest, tvbuff_t *tvb, int offset, int length) -{ -/*converts the raw buffer into printable text */ - guint32 i; - guint32 totlen=0; - const guint8 *pd = tvb_get_ptr(tvb, offset, length); - static const char hex[16] = { '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; - - for (i=0; i < (guint32)length; i++) - { - dest[totlen] = hex[pd[i] >> 4]; - totlen++; - dest[totlen] = hex[pd[i] & 0xF]; - totlen++; - } - dest[totlen]='\0'; -} - static gchar *rd_match_strval(guint32 val, const value_string *vs) { return val_to_str(val, vs, "Undefined"); } |