aboutsummaryrefslogtreecommitdiffstats
path: root/packet-icq.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2001-05-27 21:37:23 +0000
committerGuy Harris <guy@alum.mit.edu>2001-05-27 21:37:23 +0000
commitf8993291b39f8420f61f4e8564b3caf8e2f0eebc (patch)
treef914823d18626105bd2fc1f1851f8219075b5b1a /packet-icq.c
parentcce642c0f70fc6e39b1744726093c66b661d0e78 (diff)
We can't use a single static buffer for decrypted ICQ data - you might
have more than one decrypted ICQ packet visible at a time, as you might have popped up additional single-packet windows for those packets. Allocate the buffer for the decrypted data when you decrypt, and arrange that it be freed when the tvbuff that refers to it is freed. Fix the copyright notice to reflect the fact that Gerald holds the copyright on Ethereal as a whole. svn path=/trunk/; revision=3472
Diffstat (limited to 'packet-icq.c')
-rw-r--r--packet-icq.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/packet-icq.c b/packet-icq.c
index b3f88ee3cd..4fc673e0a2 100644
--- a/packet-icq.c
+++ b/packet-icq.c
@@ -1,11 +1,12 @@
/* packet-icq.c
* Routines for ICQ packet disassembly
*
- * $Id: packet-icq.c,v 1.30 2001/04/27 01:38:19 guy Exp $
+ * $Id: packet-icq.c,v 1.31 2001/05/27 21:37:23 guy Exp $
*
* Ethereal - Network traffic analyzer
- * By Johan Feyaerts
- * Copyright 1999 Johan Feyaerts
+ * By Gerald Combs <gerald@ethereal.com>
+ * Copyright 1998 Gerald Combs
+ *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -1768,26 +1769,16 @@ dissect_icqv5Client(tvbuff_t *tvb,
guint16 pktsize; /* The size of the ICQ content */
guint32 key;
guint16 cmd;
- static u_char *decr_pd = NULL; /* Decrypted content */
- static int decr_size = 0; /* Size of decrypted-content buffer */
+ guint8 *decr_pd; /* Decrypted content */
tvbuff_t *decr_tvb;
pktsize = tvb_length(tvb);
- if (decr_size == 0) {
- decr_size = sizeof(u_char) * 128;
- decr_pd = g_malloc(decr_size);
- }
-
- while (decr_size < pktsize + 3) {
- decr_size *= 2;
- decr_pd = g_realloc(decr_pd, decr_size);
- }
-
/* Get the encryption key */
key = get_v5key(tvb, pktsize);
/* Make a copy of the packet data, and decrypt it */
+ decr_pd = g_malloc(pktsize + 3); /* XXX - why +3? */
tvb_memcpy(tvb, decr_pd, 0, pktsize);
decrypt_v5(decr_pd, pktsize, key);
@@ -1795,6 +1786,10 @@ dissect_icqv5Client(tvbuff_t *tvb,
decr_tvb = tvb_new_real_data(decr_pd, pktsize, tvb_reported_length(tvb),
"Decrypted");
+ /* Arrange that the allocated packet data copy be freed when the
+ tvbuff is freed. */
+ tvb_set_free_cb(decr_tvb, g_free);
+
/* Add the tvbuff to the list of tvbuffs to which the tvbuff we
were handed refers, so it'll get cleaned up when that tvbuff
is cleaned up. */