summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2016-04-11 10:55:43 +0200
committerFlorian Weimer <fweimer@redhat.com>2016-04-11 10:55:43 +0200
commitd29fb41f4431ca35ea360498ef9d37558ce90d76 (patch)
tree1de9c7dcb0a33263b592b72bb5c2aa897f92e850
parenteb68636fed3603fcb148ac9e6f57193a806a1d27 (diff)
downloadglibc-d29fb41f4431ca35ea360498ef9d37558ce90d76.tar.gz
glibc-d29fb41f4431ca35ea360498ef9d37558ce90d76.tar.xz
glibc-d29fb41f4431ca35ea360498ef9d37558ce90d76.zip
nss_dns: Fix assertion failure in _nss_dns_getcanonname_r [BZ #19865]
-rw-r--r--ChangeLog6
-rw-r--r--resolv/nss_dns/dns-canon.c7
2 files changed, 13 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 984117de7f..c8df2c239b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2016-04-11  Florian Weimer  <fweimer@redhat.com>
+
+	[BZ #19865]
+	* resolv/nss_dns/dns-canon.c (_nss_dns_getcanonname_r): Restore
+	original buffer before retry.
+
 2016-04-10  Samuel Thibault  <samuel.thibault@ens-lyon.org>
 
 	* sysdeps/generic/ldsodefs.h (struct rtld_global_ro)
diff --git a/resolv/nss_dns/dns-canon.c b/resolv/nss_dns/dns-canon.c
index 27255fda58..fd73f19984 100644
--- a/resolv/nss_dns/dns-canon.c
+++ b/resolv/nss_dns/dns-canon.c
@@ -144,6 +144,13 @@ _nss_dns_getcanonname_r (const char *name, char *buffer, size_t buflen,
 	      ptr += sizeof (uint16_t) + __ns_get16 (ptr);
 	    }
 	}
+
+      /* Restore original buffer before retry.  */
+      if (ansp.ptr != buf)
+	{
+	  free (ansp.ptr);
+	  ansp.ptr = buf;
+	}
     }
 
  out: