aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2002-12-17 22:49:33 +0000
committerGuy Harris <guy@alum.mit.edu>2002-12-17 22:49:33 +0000
commit020effa6d0932ad010ca3358bb7e2954cf381879 (patch)
tree67724bf667efb13f8e37b2938a6ef72552c5c5d3
parentf883bb7443403333a8caedb86fad16475246b4b1 (diff)
Clean up the code a bit:
don't initialize variables that are set elsewhere before they're used; don't call "tvb_get_ptr()" to set a variable if you're not going to use that variable; make the two character-processing loops have the same structure; put the result of the XORing into an unsigned character, so it can be handed to "isprint()" without running the risk of bogus behavior if the 8th bit is set. svn path=/trunk/; revision=6796
-rw-r--r--packet-radius.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/packet-radius.c b/packet-radius.c
index 3c3beeab16..38d28bd9aa 100644
--- a/packet-radius.c
+++ b/packet-radius.c
@@ -5,7 +5,7 @@
*
* RFC 2865, RFC 2866, RFC 2867, RFC 2868, RFC 2869
*
- * $Id: packet-radius.c,v 1.71 2002/12/17 22:14:54 oabad Exp $
+ * $Id: packet-radius.c,v 1.72 2002/12/17 22:49:33 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -2370,8 +2370,9 @@ rddecryptpass(gchar *dest,tvbuff_t *tvb,int offset,int length)
md5_state_t md_ctx;
md5_byte_t digest[16];
guint32 i;
- guint32 totlen = 0;
- const guint8 *pd = tvb_get_ptr(tvb,offset,length);
+ guint32 totlen;
+ const guint8 *pd;
+ guchar c;
if (!shared_secret || !authenticator ) {
rdconvertbufftostr(dest,tvb,offset,length);
@@ -2379,7 +2380,7 @@ rddecryptpass(gchar *dest,tvbuff_t *tvb,int offset,int length)
}
dest[0] = '"';
- dest[1] = 0;
+ dest[1] = '\0';
totlen = 1;
md5_init(&md_ctx);
@@ -2387,29 +2388,31 @@ rddecryptpass(gchar *dest,tvbuff_t *tvb,int offset,int length)
md5_append(&md_ctx,authenticator,16);
md5_finish(&md_ctx,digest);
+ pd = tvb_get_ptr(tvb,offset,length);
for( i = 0 ; i < 16 && i < (guint32)length ; i++ ) {
- dest[totlen] = pd[i] ^ digest[i];
- if ( !isprint(dest[totlen])) {
- sprintf(&(dest[totlen]),"\\%03o",pd[i] ^ digest[i]);
- totlen += strlen(&(dest[totlen]));
- } else {
+ c = pd[i] ^ digest[i];
+ if ( isprint(c)) {
+ dest[totlen] = c;
totlen++;
+ } else {
+ sprintf(&(dest[totlen]),"\\%03o",c);
+ totlen += strlen(&(dest[totlen]));
}
}
while(i<(guint32)length) {
- if ( isprint((int)pd[i]) ) {
+ if ( isprint(pd[i]) ) {
dest[totlen] = (gchar)pd[i];
totlen++;
} else {
- sprintf(&(dest[totlen]), "\\%03o", pd[i]);
- totlen=totlen+strlen(&(dest[totlen]));
+ sprintf(&(dest[totlen]), "\\%03o", pd[i]);
+ totlen=totlen+strlen(&(dest[totlen]));
}
i++;
}
dest[totlen]='"';
- dest[totlen+1] = 0;
-
+ dest[totlen+1] = '\0';
}
+
static void
rdconvertbufftobinstr(gchar *dest, tvbuff_t *tvb, int offset, int length)
{