olga / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone

Blame SOURCES/glibc-rh1451308.patch

00db10
commit d62aa75af1941fca6f07e107afc447b7b248e340
00db10
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
00db10
Date:   Thu Jul 10 14:15:16 2014 +0530
00db10
00db10
    Fix crash when system has no ipv6 address [BZ #17125]
00db10
    
00db10
    Here's an updated patch to fix the crash in bug-ga2 when the system
00db10
    has no configured ipv6 address.  I have taken a different approach of
00db10
    using libc_freeres_fn instead of the libc_freeres_ptr since the former
00db10
    gives better control over what is freed; we need that since cache may
00db10
    or may not be allocated using malloc.
00db10
    
00db10
    Verified that bug-ga2 works correctly in both cases and does not have
00db10
    memory leaks in either of them.
00db10
00db10
diff --git a/sysdeps/unix/sysv/linux/check_pf.c b/sysdeps/unix/sysv/linux/check_pf.c
00db10
index 6b28a735a14f1498..757853342d2af5f4 100644
00db10
--- a/sysdeps/unix/sysv/linux/check_pf.c
00db10
+++ b/sysdeps/unix/sysv/linux/check_pf.c
00db10
@@ -62,7 +62,7 @@ static struct cached_data noai6ai_cached =
00db10
     .in6ailen = 0
00db10
   };
00db10
 
00db10
-libc_freeres_ptr (static struct cached_data *cache);
00db10
+static struct cached_data *cache;
00db10
 __libc_lock_define_initialized (static, lock);
00db10
 
00db10
 
00db10
@@ -378,6 +378,12 @@ __check_pf (bool *seen_ipv4, bool *seen_ipv6,
00db10
   *seen_ipv6 = true;
00db10
 }
00db10
 
00db10
+/* Free the cache if it has been allocated.  */
00db10
+libc_freeres_fn (freecache)
00db10
+{
00db10
+  if (cache)
00db10
+    __free_in6ai (cache->in6ai);
00db10
+}
00db10
 
00db10
 void
00db10
 __free_in6ai (struct in6addrinfo *ai)