Blob Blame History Raw
From ca7b1cd659eb0eb0ef355e3e122742abcea73287 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Wed, 2 Jul 2014 16:34:48 +0200
Subject: [PATCH 1/2] tool: call PR_Cleanup() on exit if NSPR is used

This prevents valgrind from reporting possibly lost memory that NSPR
uses for file descriptor cache and other globally allocated internal
data structures.

Upstream-commit: 24c3cdce88f39731506c287cb276e8bf4a1ce393
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
 src/tool_main.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/tool_main.c b/src/tool_main.c
index 95e9cc7..6a1ed6c 100644
--- a/src/tool_main.c
+++ b/src/tool_main.c
@@ -27,6 +27,10 @@
 #include <signal.h>
 #endif
 
+#ifdef USE_NSS
+#include <nspr.h>
+#endif
+
 #define ENABLE_CURLX_PRINTF
 /* use our own printf() functions */
 #include "curlx.h"
@@ -104,6 +108,12 @@ int main(int argc, char *argv[])
     tool_pressanykey();
 #endif
 
+#ifdef USE_NSS
+  if(PR_Initialized())
+    /* prevent valgrind from reporting possibly lost memory (fd cache, ...) */
+    PR_Cleanup();
+#endif
+
   free_config_fields(&config);
 
 #ifdef __NOVELL_LIBC__
-- 
2.1.0


From 295471f8122cf6522c36f8e3588e5b4d15a691ea Mon Sep 17 00:00:00 2001
From: Alessandro Ghedini <alessandro@ghedini.me>
Date: Thu, 17 Jul 2014 14:37:28 +0200
Subject: [PATCH 2/2] build: link curl to NSS libraries when NSS support is
 enabled

This fixes a build failure on Debian caused by commit
24c3cdce88f39731506c287cb276e8bf4a1ce393.

Bug: http://curl.haxx.se/mail/lib-2014-07/0209.html

Upstream-commit: c6e7cbb94e669b85d3eb8e015ec51d0072112133
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
 configure       | 5 ++++-
 configure.ac    | 4 ++++
 src/Makefile.am | 2 +-
 src/Makefile.in | 3 ++-
 4 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index 8741e21..c5d1817 100755
--- a/configure
+++ b/configure
@@ -913,7 +913,7 @@ LIBMETALINK_LIBS
 CURL_CA_BUNDLE
 SSL_ENABLED
 USE_AXTLS
-HAVE_NSS_INITCONTEXT
+NSS_LIBS
 USE_NSS
 USE_CYASSL
 USE_POLARSSL
@@ -23697,6 +23697,9 @@ fi
         { $as_echo "$as_me:${as_lineno-$LINENO}: detected NSS version $version" >&5
 $as_echo "$as_me: detected NSS version $version" >&6;}
 
+                NSS_LIBS=$addlib
+
+
                                         if test "x$cross_compiling" != "xyes"; then
           LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$nssprefix/lib$libsuff"
           export LD_LIBRARY_PATH
diff --git a/configure.ac b/configure.ac
index 70ef0b7..60a6b58 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2211,6 +2211,10 @@ if test "$curl_ssl_msg" = "$init_ssl_msg"; then
       if test "x$USE_NSS" = "xyes"; then
         AC_MSG_NOTICE([detected NSS version $version])
 
+        dnl needed when linking the curl tool without USE_EXPLICIT_LIB_DEPS
+        NSS_LIBS=$addlib
+        AC_SUBST([NSS_LIBS])
+
         dnl when shared libs were found in a path that the run-time
         dnl linker doesn't search through, we need to add it to
         dnl LD_LIBRARY_PATH to prevent further configure tests to fail
diff --git a/src/Makefile.am b/src/Makefile.am
index af5a488..6863078 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -60,7 +60,7 @@ LIBS = $(BLANK_AT_MAKETIME)
 if USE_EXPLICIT_LIB_DEPS
 curl_LDADD = $(top_builddir)/lib/libcurl.la @LIBMETALINK_LIBS@ @LIBCURL_LIBS@
 else
-curl_LDADD = $(top_builddir)/lib/libcurl.la @LIBMETALINK_LIBS@ @ZLIB_LIBS@ @CURL_NETWORK_AND_TIME_LIBS@
+curl_LDADD = $(top_builddir)/lib/libcurl.la @LIBMETALINK_LIBS@ @NSS_LIBS@ @ZLIB_LIBS@ @CURL_NETWORK_AND_TIME_LIBS@
 endif
 
 curl_LDFLAGS = @LIBMETALINK_LDFLAGS@
diff --git a/src/Makefile.in b/src/Makefile.in
index 41fb549..1b578c2 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -231,6 +231,7 @@ NMEDIT = @NMEDIT@
 # Use the C locale to ensure that only ASCII characters appear in the
 # embedded text.
 NROFF = env LC_ALL=C @NROFF@ @MANOPT@ # figured out by the configure script
+NSS_LIBS = @NSS_LIBS@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
@@ -463,7 +464,7 @@ CURL_HFILES = \
 	tool_xattr.h
 
 curl_SOURCES = $(CURL_CFILES) $(CURLX_ONES) $(CURL_HFILES)
-@USE_EXPLICIT_LIB_DEPS_FALSE@curl_LDADD = $(top_builddir)/lib/libcurl.la @LIBMETALINK_LIBS@ @ZLIB_LIBS@ @CURL_NETWORK_AND_TIME_LIBS@
+@USE_EXPLICIT_LIB_DEPS_FALSE@curl_LDADD = $(top_builddir)/lib/libcurl.la @LIBMETALINK_LIBS@ @NSS_LIBS@ @ZLIB_LIBS@ @CURL_NETWORK_AND_TIME_LIBS@
 @USE_EXPLICIT_LIB_DEPS_TRUE@curl_LDADD = $(top_builddir)/lib/libcurl.la @LIBMETALINK_LIBS@ @LIBCURL_LIBS@
 curl_LDFLAGS = @LIBMETALINK_LDFLAGS@
 curl_CPPFLAGS = $(AM_CPPFLAGS) $(LIBMETALINK_CPPFLAGS)
-- 
2.1.0