]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix crash when system has no ipv6 address [BZ #17125]
authorSiddhesh Poyarekar <siddhesh@redhat.com>
Thu, 10 Jul 2014 08:45:16 +0000 (14:15 +0530)
committerSiddhesh Poyarekar <siddhesh@redhat.com>
Thu, 10 Jul 2014 08:45:16 +0000 (14:15 +0530)
Here's an updated patch to fix the crash in bug-ga2 when the system
has no configured ipv6 address.  I have taken a different approach of
using libc_freeres_fn instead of the libc_freeres_ptr since the former
gives better control over what is freed; we need that since cache may
or may not be allocated using malloc.

Verified that bug-ga2 works correctly in both cases and does not have
memory leaks in either of them.

ChangeLog
NEWS
sysdeps/unix/sysv/linux/check_pf.c

index f5b5599486c268605d3e7b3114ad5fc073209f72..72e9cf9e2809a1a8f9d251683ef43f8e9ff72b69 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2014-07-10  Siddhesh Poyarekar  <siddhesh@redhat.com>
 
+       [BZ #17125]
+       * sysdeps/unix/sysv/linux/check_pf.c (cache): Don't use
+       libc_freeres_ptr.
+       (freecache): New function to free CACHE on exit.
+
        * sunrpc/xdr.c (xdr_string): Add comment about SIZE
        initialization.
 
diff --git a/NEWS b/NEWS
index f4c501ca568276782082d99240d371b793955ade..3ef9162fbb9bd5b01b425c1a431f15a36a690f99 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -21,7 +21,7 @@ Version 2.20
   16882, 16885, 16888, 16890, 16912, 16915, 16916, 16917, 16918, 16922,
   16927, 16928, 16932, 16943, 16958, 16965, 16966, 16967, 16977, 16978,
   16984, 16990, 16996, 17009, 17022, 17031, 17042, 17048, 17050, 17058,
-  17061, 17062, 17069, 17075, 17079, 17084, 17086, 17092, 17097.
+  17061, 17062, 17069, 17075, 17079, 17084, 17086, 17092, 17097, 17125.
 
 * Optimized strchr implementation for AArch64.  Contributed by ARM Ltd.
 
index 1bc1def72f13ec0deeb52e7b04261d6059a029c0..c7fd9b0376a58cf8720d3d7b4f82b46dbe6223da 100644 (file)
@@ -61,7 +61,7 @@ static struct cached_data noai6ai_cached =
     .in6ailen = 0
   };
 
-libc_freeres_ptr (static struct cached_data *cache);
+static struct cached_data *cache;
 __libc_lock_define_initialized (static, lock);
 
 
@@ -401,6 +401,12 @@ __check_pf (bool *seen_ipv4, bool *seen_ipv6,
   *seen_ipv6 = true;
 }
 
+/* Free the cache if it has been allocated.  */
+libc_freeres_fn (freecache)
+{
+  if (cache)
+    __free_in6ai (cache->in6ai);
+}
 
 void
 __free_in6ai (struct in6addrinfo *ai)