From a44841cbe2abe712de84d7413c31fc14b44225a7 Mon Sep 17 00:00:00 2001 From: Darshit Shah Date: Mon, 21 Jul 2014 13:25:54 +0530 Subject: [PATCH] Fix potential memory leak and libpsl configure --- ChangeLog | 4 ++++ configure.ac | 16 +++++++++------- src/ChangeLog | 5 +++++ src/cookies.c | 5 ++++- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2bfae67d..0cba66da 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-07-21 Darshit Shah + + * configure.ac: Fix check for Libpsl + 2014-06-28 Giuseppe Scrivano * cfg.mk (local-checks-to-skip): Remove some checks. diff --git a/configure.ac b/configure.ac index abc92fb0..56edc001 100644 --- a/configure.ac +++ b/configure.ac @@ -63,7 +63,14 @@ dnl AC_ARG_WITH(libpsl, AS_HELP_STRING([--without-libpsl], - [disable support for libpsl cookie checking.])) + [disable support for libpsl cookie checking.]), + [], + [AC_SEARCH_LIBS(psl_builtin, psl, + [AC_DEFINE([WITH_LIBPSL], [1], [PSL Support Enabled])], + [AC_MSG_WARN(*** libpsl not found. Falling back to tail matching)]) + ]) +AS_IF([test x$ac_cv_search_psl_builtin != "x-psl"], [ENABLE_PSL=no], + [ENABLE_PSL=yes]) AC_ARG_WITH(ssl, [[ --without-ssl disable SSL autodetection @@ -238,11 +245,6 @@ dnl dnl Checks for libraries. dnl -AS_IF([test x"$with_libpsl" != xno], [ - with_libpsl=yes - AC_CHECK_LIB([psl], [psl_builtin]) -]) - AS_IF([test x"$with_zlib" != xno], [ with_zlib=yes AC_CHECK_LIB(z, compress) @@ -593,7 +595,7 @@ AC_MSG_NOTICE([Summary of build options: Libs: $LIBS SSL: $with_ssl Zlib: $with_zlib - PSL: $with_libpsl + PSL: $ENABLE_PSL Digest: $ENABLE_DIGEST NTLM: $ENABLE_NTLM OPIE: $ENABLE_OPIE diff --git a/src/ChangeLog b/src/ChangeLog index 91eda5f0..e668583f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2014-07-21 Darshit Shah + + * cookies.c (check_domain_match): Fix a potential memory leak when checking + cookie domain names + 2014-07-07 Tomas Hozza * iri.c (locale_to_utf8): Fix checking of iconv_open return code. diff --git a/src/cookies.c b/src/cookies.c index 76301acc..bf872a88 100644 --- a/src/cookies.c +++ b/src/cookies.c @@ -546,9 +546,12 @@ check_domain_match (const char *cookie_domain, const char *host) xfree (cookie_domain_lower); xfree (host_lower); - return true ? (is_acceptable == 1) : false; + return is_acceptable == 1; no_psl: + /* Cleanup the PSL pointers first */ + xfree (cookie_domain_lower); + xfree (host_lower); #endif /* For efficiency make some elementary checks first */