[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-wget] Memory leak when using GnuTLS

From: Gijs van Tulder
Subject: [Bug-wget] Memory leak when using GnuTLS
Date: Tue, 01 Nov 2011 00:14:45 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1


I think there is a memory leak in the GnuTLS part of wget. When downloading multiple files from a HTTPS server, wget with GnuTLS uses a lot of memory.

Perhaps an explanation for this can be found in src/http.c. The gethttp calls ssl_init for each download:

> /* Initialize the SSL context.  After this has once been done,
>    it becomes a no-op.  */
> if (!ssl_init ())

The OpenSSL version of ssl_init, in src/openssl.c, checks if SSL has already been initialized and doesn't repeat the work.

But the GnuTLS version doesn't:

> bool
> ssl_init ()
> {
>   const char *ca_directory;
>   DIR *dir;
>   gnutls_global_init ();
>   gnutls_certificate_allocate_credentials (&credentials);

GnuTLS is initialized again and again, but there is never a call to gnutls_global_deinit.

I've attached a small patch to add a check to ssl_init in src/gnutls.c, similar to the check already in src/openssl.c. With it, wget can still download over HTTPS and the memory usage stays within reasonable limits.



Attachment: gnutls-initialize-only-once.patch
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]