Re: memory leak in inflate.c

2005-03-15 Thread Marc Olzheim
On Mon, Mar 14, 2005 at 09:43:52PM +0100, Marco Molteni wrote:
 On Mon, 14 Mar 2005 [EMAIL PROTECTED] wrote:
  Hi, I am trying to debug a memory leak in executing gzipped binaries
  ^^
  when the parameter list is too long. The function in question is
  inflate_dynamic(). 

 _If_ I remember correctly, if inflate_dynamic() returns a non-zero
 code it means that the decompression failed and the program itself
 quits right away, no memory leak. Or am I missing something?

Your missing something: /usr/src/sys/kern/inflate.c ;-)

Looks like a good patch to me.

Marc


pgpGxhud3Bc5I.pgp
Description: PGP signature


RE: memory leak in inflate.c

2005-03-15 Thread Vijay.Singh
Thanks. Could someone generate the patch as I dont have the latest
FreeBSD source checked out.

br
vijay

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of ext Marc Olzheim
Sent: Tuesday, March 15, 2005 11:31 AM
To: Marco Molteni
Cc: freebsd-hackers@freebsd.org
Subject: Re: memory leak in inflate.c


On Mon, Mar 14, 2005 at 09:43:52PM +0100, Marco Molteni wrote:
 On Mon, 14 Mar 2005 [EMAIL PROTECTED] wrote:
  Hi, I am trying to debug a memory leak in executing gzipped binaries
  ^^
  when the parameter list is too long. The function in question is
  inflate_dynamic(). 

 _If_ I remember correctly, if inflate_dynamic() returns a non-zero
 code it means that the decompression failed and the program itself
 quits right away, no memory leak. Or am I missing something?

Your missing something: /usr/src/sys/kern/inflate.c ;-)

Looks like a good patch to me.

Marc
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: memory leak in inflate.c

2005-03-15 Thread Marc Olzheim
On Tue, Mar 15, 2005 at 12:15:11PM -0800, [EMAIL PROTECTED] wrote:
 Thanks. Could someone generate the patch as I dont have the latest
 FreeBSD source checked out.

Hmm, there seem to be more possible leaks, as the code has been
literally copied from /usr/src/gnu/usr.bin/gzip/, including the define
of PKZIP_BUG_WORKAROUND. Have you checked all possible problems, or did
you just stumble onto this one ?

Marc


pgpmtFKH4ORVV.pgp
Description: PGP signature


Re: memory leak in inflate.c

2005-03-15 Thread Marc Olzheim
On Tue, Mar 15, 2005 at 09:42:07PM +0100, Marc Olzheim wrote:
  Thanks. Could someone generate the patch as I dont have the latest
  FreeBSD source checked out.
 
 Hmm, there seem to be more possible leaks, as the code has been
 literally copied from /usr/src/gnu/usr.bin/gzip/, including the define
 of PKZIP_BUG_WORKAROUND. Have you checked all possible problems, or did
 you just stumble onto this one ?

Ah, never mind, that PKZIP_BUG_WORKAROUND part seems to be ok.

Here it is.

Marc
--- kern/inflate.c  Tue Mar 15 21:46:14 2005
+++ kern/inflate.c  Tue Mar 15 21:46:22 2005
@@ -956,14 +956,15 @@
return i;   /* incomplete code set */
 #endif
}
+
/* decompress until an end-of-block code */
-   if (inflate_codes(glbl, tl, td, bl, bd))
-   return 1;
+   i = (inflate_codes(glbl, tl, td, bl, bd)) ? 1 : 0;
 
/* free the decoding tables, return */
huft_free(glbl, tl);
huft_free(glbl, td);
-   return 0;
+
+   return i;
 }
 
 /* decompress an inflated block */


pgpehXhX6L819.pgp
Description: PGP signature


memory leak in inflate.c

2005-03-14 Thread Vijay.Singh
Hi, I am trying to debug a memory leak in executing gzipped binaries when the 
parameter list is too long. The function in question is inflate_dynamic(). 

/* decompress until an end-of-block code */
if (inflate_codes(glbl, tl, td, bl, bd))
return 1;

/* free the decoding tables, return */
huft_free(glbl, tl);
huft_free(glbl, td);
return 0;


Should this be re-written as:

i = inflate_codes(glbl, tl, td, bl, bd) ? 1 : 0;

/* free the decoding tables, return */
huft_free(glbl, tl);
huft_free(glbl, td);

return (i);

so that the Huffman tables are always freed.

Comments appreciated.

br
vijay


___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: memory leak in inflate.c

2005-03-14 Thread Marco Molteni
On Mon, 14 Mar 2005 [EMAIL PROTECTED] wrote:

 Hi, I am trying to debug a memory leak in executing gzipped binaries
 when the parameter list is too long. The function in question is
 inflate_dynamic(). 
 
 /* decompress until an end-of-block code */
 if (inflate_codes(glbl, tl, td, bl, bd))
 return 1;
 
 /* free the decoding tables, return */
 huft_free(glbl, tl);
 huft_free(glbl, td);
 return 0;
 
 
 Should this be re-written as:
 
   i = inflate_codes(glbl, tl, td, bl, bd) ? 1 : 0;
 
   /* free the decoding tables, return */
   huft_free(glbl, tl);
   huft_free(glbl, td);
 
   return (i);
 
 so that the Huffman tables are always freed.

_If_ I remember correctly, if inflate_dynamic() returns a non-zero
code it means that the decompression failed and the program itself
quits right away, no memory leak. Or am I missing something?

marco
-- 
Very graphic, classical but efficient.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]