Ethereal-dev: [Ethereal-dev] patch for giop segfault

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Frank Singleton <frank.singleton@xxxxxxxxxxxx>
Date: Thu, 26 Jul 2001 11:21:40 -0500
Hi,

Well after your constructive comments, I played with 
gdb and efence for a while and found a premature memory 
deallocation.

Summary
-------

Inside decode_IOR(), a buffer is allocated to hold
repository id (repobuf).

If , when decoding an IOR, we call decode_TaggedProfile()
"n" amount of times, to decode "Tagged Profiles", then 
decode_TaggedProfile() was doing a premature g_free(repo_id_buf)
when in fact it should not have been doing it at all.

g_free() should not be called here, but at the end 
of decode_IOR().

I have attached a patch to fix this :-)


/Frank..

-- 
EUS/SV/Z Frank Singleton      ASO Americas BSS
Office : +1 972 583 3251      ECN 800 33251  
Mobile : +1 214 228 0874      Amateur Radio: VK3FCS/KM5WS   
Email : frank.singleton@xxxxxxxxxxxx

Hardware: HP Omnibook 4150 running Redhat Linux 7.1 (2.4.3-12 kernel).
--- ../ethereal-2001-07-26/packet-giop.c	Wed Jul 25 15:21:57 2001
+++ ../ethereal-2001-07-26.upated/packet-giop.c	Thu Jul 26 10:36:55 2001
@@ -9,7 +9,7 @@
  * Frank Singleton <frank.singleton@xxxxxxxxxxxx>
  * Trevor Shepherd <eustrsd@xxxxxxxxxxxxxxx>
  *
- * $Id: packet-giop.c,v 1.43 2001/07/25 20:21:57 guy Exp $
+ * $Id: packet-giop.c,v 1.2 2001/07/26 15:36:55 frank Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@xxxxxxxxxxxx>
@@ -4329,7 +4329,9 @@
   for (i=0; i< seqlen_p; i++) { /* for every TaggedProfile */
     decode_TaggedProfile(tvb, pinfo, tree, offset, boundary, stream_is_big_endian, repobuf);
   }
-  
+
+  g_free(repobuf);
+
 }
 
 static void decode_TaggedProfile(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int *offset,
@@ -4515,7 +4517,6 @@
     }
   }
   
-  g_free(repo_id_buf);
   g_free(objkey);  
   g_free(p_chars);  
   p_chars = NULL;               /* reuse later */