Ethereal-dev: Re: [Ethereal-dev] HTTP gzip/deflate decompression patch

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

From: Kendy Kutzner <kutzner@xxxxxxxxx>
Date: Wed, 5 May 2004 14:05:36 +0200
On 2004-05-02T20:47:33-0700, Jerry Talkington wrote:
> I didn't convert and remove the Soul Seek uncompress functions,
> because I couldn't test it.

Patch for slsk attached. I think there are still problems with
LIBZ and autoconf in the epan directory.

Kendy

-- 

Index: packet-slsk.c
===================================================================
RCS file: /cvsroot/ethereal/packet-slsk.c,v
retrieving revision 1.3
diff -u -r1.3 packet-slsk.c
--- packet-slsk.c	17 Mar 2004 09:01:16 -0000	1.3
+++ packet-slsk.c	5 May 2004 12:01:48 -0000
@@ -41,11 +41,8 @@
 
 #include <glib.h>
 
-#ifdef HAVE_LIBZ
-#include <zlib.h>
-#endif
-
 #include <epan/packet.h>
+#include <epan/tvbuff.h>
 #include "packet-tcp.h"
 #include "prefs.h"
 
@@ -295,50 +292,6 @@
 	return msg_len;
 }
 
-#ifdef HAVE_LIBZ
-static tvbuff_t* uncompress_packet(tvbuff_t *tvb, int offset, int comprlen){
-	
-	/*
-	* Uncompresses a zlib compressed packet inside a message of tvb at offset with length comprlen
-	* Returns an uncompressed tvbuffer if uncompression succeeded
-	*             or NULL if uncompression failed
-	*/
-	
-	int err;
-	long uncomprlen = (comprlen*10);
-	guint8 * compr;
-	guint8 * uncompr;
-	tvbuff_t *uncompr_tvb;
-
-	compr = tvb_memdup(tvb, offset, comprlen);
-	if (!compr)
-		return NULL;
-
-	uncompr = g_malloc(uncomprlen);
-	if (!uncompr){
-		g_free(compr);
-		return NULL;
-	}
-
-	err = uncompress((Bytef *)uncompr, &uncomprlen, (Bytef *)compr, comprlen);
-	g_free(compr);
-	if (err != 0) {
-		g_free(uncompr);
-		return NULL;
-	}
-	
-	uncompr_tvb =  tvb_new_real_data((guint8*) uncompr, uncomprlen, uncomprlen);
-	g_free(uncompr);
-	return uncompr_tvb;
-}
-#else
-static tvbuff_t* uncompress_packet(tvbuff_t *tvb _U_, int offset _U_, int comprlen _U_){
-	return NULL;
-}
-#endif
-
-
-
 /* Code to actually dissect the packets */
 
 static void dissect_slsk_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
@@ -514,7 +467,7 @@
 					
 					if (slsk_decompress == TRUE){
 							
-						tvbuff_t *uncompr_tvb = uncompress_packet(tvb, offset, comprlen);
+						tvbuff_t *uncompr_tvb = tvb_uncompress(tvb, offset, comprlen);
 			
 						if (uncompr_tvb == NULL) {
 							proto_tree_add_uint_format(slsk_tree, hf_slsk_integer, tvb, offset, tvb_length_remaining(tvb, offset), 0,
@@ -646,7 +599,7 @@
 					
 					if (slsk_decompress == TRUE){
 							
-						tvbuff_t *uncompr_tvb = uncompress_packet(tvb, offset, comprlen);
+						tvbuff_t *uncompr_tvb = tvb_uncompress(tvb, offset, comprlen);
 			
 						if (uncompr_tvb == NULL) {
 							proto_tree_add_uint_format(slsk_tree, hf_slsk_integer, tvb, offset, tvb_length_remaining(tvb, offset), 0,
@@ -1161,7 +1114,7 @@
 					
 					if (slsk_decompress == TRUE){
 							
-						tvbuff_t *uncompr_tvb = uncompress_packet(tvb, offset, comprlen);
+						tvbuff_t *uncompr_tvb = tvb_uncompress(tvb, offset, comprlen);
 			
 						if (uncompr_tvb == NULL) {
 							proto_tree_add_uint_format(slsk_tree, hf_slsk_integer, tvb, offset, tvb_length_remaining(tvb, offset), 0,
Index: AUTHORS
===================================================================
RCS file: /cvsroot/ethereal/AUTHORS,v
retrieving revision 1.1008
diff -u -r1.1008 AUTHORS
--- AUTHORS	5 May 2004 06:55:09 -0000	1.1008
+++ AUTHORS	5 May 2004 12:01:49 -0000
@@ -2157,6 +2157,7 @@
 	Jon Oberheide <jon [AT] focalhost.com>
 	Clinton Work <clinton [AT] scripty.com>
 	Joe Marcus Clarke <marcus [AT] marcuscom.com>
+	Kendy Kutzner <kutzner [AT] tm.uka.de>
 
 Alain Magloire <alainm[AT]rcsm.ece.mcgill.ca> was kind enough to
 give his permission to use his version of snprintf.c.

Attachment: pgpEFauBy7MJb.pgp
Description: PGP signature