diff --git a/debian/bug/libc6-i386.presubj b/debian/bug/libc6-i386.presubj
new file mode 100644
index 0000000..b5ac12d
--- /dev/null
+++ b/debian/bug/libc6-i386.presubj
@@ -0,0 +1,14 @@
+issues with /usr/lib32
+======================
+
+  libc6-i386 is the sole package that is supposed to ship /usr/lib32.
+
+  If you get a problem like:
+      Unpacking replacement libc6-i386 ...
+      dpkg: error processing
+        /var/cache/apt/archives/libc6-i386_2.6-2_amd64.deb (--unpack):
+      trying to overwrite `/usr/lib32', which is also in package libfoo32xxx
+                                                                 ^^^^^^^^^^^
+
+  Then the package libfoo32xxx is at fault, do _NOT_ report a bug on libc6-i386.
+
diff --git a/debian/changelog b/debian/changelog
index e29ee7d..5eed53b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,37 @@
+glibc (2.3.6.ds1-13etch3) stable; urgency=low
+
+  * patches/any/cvs-nscd-free.diff: fix nscd crash. Closes: #425404.
+
+ -- Aurelien Jarno <aurel32@debian.org>  Mon, 02 Jul 2007 00:59:13 +0200
+
+glibc (2.3.6.ds1-13etch2) stable; urgency=low
+
+  * patches/any/cvs-vfprintf-stack-smashing.diff: fix issue with 8bits locales
+    and printf exploding the stack with large width specifiers.
+  * patches/any/cvs-getnetgrent_r-memory-leak.diff: fix memory leak in
+    getnetgrent_r. Closes: #423369.
+
+ -- Pierre Habouzit <madcoder@debian.org>  Tue, 15 May 2007 14:07:40 +0200
+
+glibc (2.3.6.ds1-13etch1) stable; urgency=low
+
+  [ Pierre Habouzit ]
+  * any/cvs-sunrpc-64bits-svc_getreqset.diff: fix 64bits issue for 64bits
+    machines  (affects mount, causes CPU hog if triggered). Closes: #413450.
+  * control.in/main, rules.d/debhelper.mk: Backport fix from Aurélien in the
+    glibc-2.5 branch: use dh_shlibdeps to set the dependencies of nscd.
+    Closes: #409288, #412562.
+
+  [ Aurelien Jarno ]
+  * patches/any/cvs-nss_nis_setnetgrent.diff: new patch from upstream (fix
+    a wrong assertion in nss_nis_setnetgrent.  Closes: #369536.
+  * patches/any/submitted-gethostbyname_r.diff: new patch to fix unaligned
+    memory access in gethostbyname_r.diff().  Closes: #419459.
+  * debian/patches/alpha/local-waitpid-not-cancel.diff: new patch (fix defunct
+    threads on alpha) from Uwe Schindler.  Closes: #325600.
+
+ -- Aurelien Jarno <aurel32@debian.org>  Fri, 20 Apr 2007 00:09:51 +0200
+
 glibc (2.3.6.ds1-13) unstable; urgency=low
 
   * debhelper.in/libc.postinst: try to add /etc/ld.so.conf.d support for
diff --git a/debian/control b/debian/control
index bdff947..a846f61 100644
--- a/debian/control
+++ b/debian/control
@@ -58,7 +58,7 @@ Package: nscd
 Architecture: alpha amd64 arm arm-softfloat armeb i386 m32r m68k mips mipsel powerpc ppc64 sparc ia64 hppa s390 sh3 sh4 sh3eb sh4eb kfreebsd-i386 kfreebsd-amd64 
 Section: admin
 Priority: optional
-Depends: libc6 (>= ${Source-Version})
+Depends: ${shlibs:Depends}
 Description: GNU C Library: Name Service Cache Daemon
  A daemon which handles passwd, group and host lookups
  for running programs and caches the results for the next
diff --git a/debian/control.in/main b/debian/control.in/main
index 83762e2..bde7bc2 100644
--- a/debian/control.in/main
+++ b/debian/control.in/main
@@ -58,7 +58,7 @@ Package: nscd
 Architecture: @threads_archs@
 Section: admin
 Priority: optional
-Depends: @libc@ (>= ${Source-Version})
+Depends: ${shlibs:Depends}
 Description: GNU C Library: Name Service Cache Daemon
  A daemon which handles passwd, group and host lookups
  for running programs and caches the results for the next
diff --git a/debian/patches/alpha/local-waitpid-not-cancel.diff b/debian/patches/alpha/local-waitpid-not-cancel.diff
new file mode 100644
index 0000000..6a69054
--- /dev/null
+++ b/debian/patches/alpha/local-waitpid-not-cancel.diff
@@ -0,0 +1,17 @@
+diff -ur sysdeps/unix/sysv/linux/not-cancel.h sysdeps/unix/sysv/linux/not-cancel.h
+--- sysdeps/unix/sysv/linux/not-cancel.h	2003-09-04 16:05:12.000000000 +0200
++++ sysdeps/unix/sysv/linux/not-cancel.h	2007-04-19 13:46:59.000000000 +0200
+@@ -55,6 +55,11 @@
+ # define waitpid_not_cancel(pid, stat_loc, options) \
+   INLINE_SYSCALL (waitpid, 3, pid, stat_loc, options)
+ #else
+-# define waitpid_not_cancel(pid, stat_loc, options) \
+-  INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL)
++# if defined(__alpha__) 
++#  define waitpid_not_cancel(pid, stat_loc, options) \
++   wait4(pid, stat_loc, options, NULL)
++# else
++#  define waitpid_not_cancel(pid, stat_loc, options) \
++   INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL)
++# endif
+ #endif
diff --git a/debian/patches/any/cvs-getnetgrent_r-memory-leak.diff b/debian/patches/any/cvs-getnetgrent_r-memory-leak.diff
new file mode 100644
index 0000000..1507668
--- /dev/null
+++ b/debian/patches/any/cvs-getnetgrent_r-memory-leak.diff
@@ -0,0 +1,37 @@
+#2005-09-24  Jakub Jelinek  <jakub@redhat.com>
+#
+#       * inet/getnetgrent_r.c (innetgr): Call endfct even if result != 0.
+#       Return 1 only if result == 1.  Patch by Benoit Capelle.
+#
+Index: glibc-2.3.6/inet/getnetgrent_r.c
+===================================================================
+--- glibc-2.3.6.orig/inet/getnetgrent_r.c	2007-05-15 14:34:38.302725105 +0200
++++ glibc-2.3.6/inet/getnetgrent_r.c	2007-05-15 14:34:51.427473042 +0200
+@@ -405,9 +405,6 @@
+ 		    }
+ 		}
+ 
+-	      if (result != 0)
+-		break;
+-
+ 	      /* If we found one service which does know the given
+ 		 netgroup we don't try further.  */
+ 	      status = NSS_STATUS_RETURN;
+@@ -417,6 +414,9 @@
+ 	  if (__nss_lookup (&entry.nip, "endnetgrent", &endfct.ptr) == 0)
+ 	    (*endfct.f) (&entry);
+ 
++	  if (result != 0)
++	    break;
++
+ 	  /* Look for the next service.  */
+ 	  no_more = __nss_next (&entry.nip, "setnetgrent",
+ 				&setfct.ptr, status, 0);
+@@ -439,6 +439,6 @@
+   /* Free the memory.  */
+   free_memory (&entry);
+ 
+-  return result;
++  return result == 1;
+ }
+ libc_hidden_def (innetgr)
diff --git a/debian/patches/any/cvs-nscd-free.diff b/debian/patches/any/cvs-nscd-free.diff
new file mode 100644
index 0000000..ea1a06a
--- /dev/null
+++ b/debian/patches/any/cvs-nscd-free.diff
@@ -0,0 +1,22 @@
+2005-09-22  Ulrich Drepper  <drepper@redhat.com>
+
+	[BZ #1363]
+	* nscd/nscd_getpw_r.c (nscd_getpw_r): Remove incorrectly C&Ped
+	free call in code handling detection of GC runs.
+
+===================================================================
+RCS file: /cvs/glibc/libc/nscd/nscd_getpw_r.c,v
+retrieving revision 1.30
+retrieving revision 1.31
+diff -u -r1.30 -r1.31
+--- libc/nscd/nscd_getpw_r.c	2005/02/22 22:47:45	1.30
++++ libc/nscd/nscd_getpw_r.c	2005/09/22 14:35:11	1.31
+@@ -227,8 +227,6 @@
+ 	  mapped = NO_MAPPING;
+ 	}
+ 
+-      free (resultbuf);
+-
+       goto retry;
+     }
+ 
diff --git a/debian/patches/any/cvs-nss_nis_setnetgrent.diff b/debian/patches/any/cvs-nss_nis_setnetgrent.diff
new file mode 100644
index 0000000..b3d3057
--- /dev/null
+++ b/debian/patches/any/cvs-nss_nis_setnetgrent.diff
@@ -0,0 +1,16 @@
+Index: nis/nss_nis/nis-netgrp.c
+===================================================================
+RCS file: /cvs/glibc/libc/nis/nss_nis/nis-netgrp.c,v
+retrieving revision 1.12
+diff -u -p -r1.12 nis-netgrp.c
+--- nis/nss_nis/nis-netgrp.c	14 Aug 2004 04:20:34 -0000	1.12
++++ nis/nss_nis/nis-netgrp.c	7 Aug 2005 04:15:29 -0000
+@@ -75,7 +75,7 @@ _nss_nis_setnetgrent (const char *group,
+ 	 which is one byte larger than the value in LEN specifies
+ 	 and the last byte is filled with NUL.  So we can simply
+ 	 use that buffer.  */
+-      assert (len > 0);
++      assert (len >= 0);
+       assert (malloc_usable_size (netgrp->data) >= len + 1);
+       assert (netgrp->data[len] == '\0');
+ 
diff --git a/debian/patches/any/cvs-sunrpc-64bits-svc_getreqset.diff b/debian/patches/any/cvs-sunrpc-64bits-svc_getreqset.diff
new file mode 100644
index 0000000..bee7809
--- /dev/null
+++ b/debian/patches/any/cvs-sunrpc-64bits-svc_getreqset.diff
@@ -0,0 +1,13 @@
+Index: sunrpc/svc.c
+===================================================================
+--- sunrpc/svc.c.orig
++++ sunrpc/svc.c
+@@ -372,7 +372,7 @@
+     setsize = FD_SETSIZE;
+   maskp = readfds->fds_bits;
+   for (sock = 0; sock < setsize; sock += NFDBITS)
+-    for (mask = *maskp++; (bit = ffs (mask)); mask ^= (1 << (bit - 1)))
++    for (mask = *maskp++; (bit = ffsl (mask)); mask ^= (1 << (bit - 1)))
+       INTUSE(svc_getreq_common) (sock + bit - 1);
+ }
+ INTDEF (svc_getreqset)
diff --git a/debian/patches/any/cvs-vfprintf-stack-smashing.diff b/debian/patches/any/cvs-vfprintf-stack-smashing.diff
new file mode 100644
index 0000000..3f477c3
--- /dev/null
+++ b/debian/patches/any/cvs-vfprintf-stack-smashing.diff
@@ -0,0 +1,55 @@
+2007-05-02  Jakub Jelinek  <jakub@redhat.com>
+
+	* stdio-common/vfprintf.c (process_string_arg): Use a VLA rather than
+	fixed length array for ignore.
+
+2007-04-30  Ulrich Drepper  <drepper@redhat.com>
+
+	[BZ #4438]
+	* stdio-common/vfprintf.c (process_string_arg): Don't overflow the
+	stack for large precisions.
+
+===================================================================
+RCS file: /cvs/glibc/libc/stdio-common/vfprintf.c,v
+retrieving revision 1.135
+retrieving revision 1.137
+Index: glibc-2.5/stdio-common/vfprintf.c
+===================================================================
+--- glibc-2.5.orig/stdio-common/vfprintf.c	2006-05-02 22:25:15.000000000 +0200
++++ glibc-2.5/stdio-common/vfprintf.c	2007-05-04 11:26:16.049828248 +0200
+@@ -1159,19 +1159,26 @@
+ 		else							      \
+ 		  {							      \
+ 		    /* In case we have a multibyte character set the	      \
+-		       situation is more compilcated.  We must not copy	      \
++		       situation is more complicated.  We must not copy	      \
+ 		       bytes at the end which form an incomplete character. */\
+-		    wchar_t ignore[prec];				      \
++		    size_t ignore_size = (unsigned) prec > 1024 ? 1024 : prec;\
++		    wchar_t ignore[ignore_size];			      \
+ 		    const char *str2 = string;				      \
+-		    mbstate_t ps;					      \
++		    const char *strend = string + prec;			      \
++		    if (strend < string)				      \
++		      strend = (const char *) UINTPTR_MAX;		      \
+ 									      \
++		    mbstate_t ps;					      \
+ 		    memset (&ps, '\0', sizeof (ps));			      \
+-		    if (__mbsnrtowcs (ignore, &str2, prec, prec, &ps)	      \
+-			== (size_t) -1)					      \
+-		      {							      \
+-			done = -1;					      \
+-			goto all_done;					      \
+-		      }							      \
++									      \
++		    while (str2 != NULL && str2 < strend)		      \
++		      if (__mbsnrtowcs (ignore, &str2, strend - str2,	      \
++					ignore_size, &ps) == (size_t) -1)     \
++			{						      \
++			  done = -1;					      \
++			  goto all_done;				      \
++			}						      \
++									      \
+ 		    if (str2 == NULL)					      \
+ 		      len = strlen (string);				      \
+ 		    else						      \
diff --git a/debian/patches/any/submitted-gethostbyname_r.diff b/debian/patches/any/submitted-gethostbyname_r.diff
new file mode 100644
index 0000000..6574113
--- /dev/null
+++ b/debian/patches/any/submitted-gethostbyname_r.diff
@@ -0,0 +1,32 @@
+--- resolv/nss_dns/dns-host.c.orig	2007-04-16 00:13:12.000000000 +0200
++++ resolv/nss_dns/dns-host.c	2007-04-16 00:34:41.000000000 +0200
+@@ -78,6 +78,7 @@
+ #include <stdlib.h>
+ #include <stddef.h>
+ #include <string.h>
++#include <obstack.h>
+ #include <sys/syslog.h>
+ 
+ #include "nsswitch.h"
+@@ -465,8 +466,8 @@
+     char *aliases[MAX_NR_ALIASES];
+     unsigned char host_addr[16];	/* IPv4 or IPv6 */
+     char *h_addr_ptrs[0];
+-  } *host_data = (struct host_data *) buffer;
+-  int linebuflen = buflen - sizeof (struct host_data);
++  } *host_data;
++  int linebuflen;
+   register const HEADER *hp;
+   const u_char *end_of_message, *cp;
+   int n, ancount, qdcount;
+@@ -479,6 +480,10 @@
+   int have_to_map = 0;
+   int32_t ttl = 0;
+ 
++  /* Align the buffer. */
++  host_data = (struct host_data *) (((intptr_t) buffer + (sizeof(char*) - 1)) & ~(sizeof(char*) - 1));
++  linebuflen = buflen - sizeof (struct host_data) - ((char *)host_data - buffer);
++
+   if (__builtin_expect (linebuflen, 0) < 0)
+     {
+       /* The buffer is too small.  */
diff --git a/debian/patches/any/submitted-nis-netgrp.diff b/debian/patches/any/submitted-nis-netgrp.diff
index 95899c5..00cfefc 100644
--- a/debian/patches/any/submitted-nis-netgrp.diff
+++ b/debian/patches/any/submitted-nis-netgrp.diff
@@ -16,7 +16,7 @@ Index: glibc-2.3.5/nis/nss_nis/nis-netgrp.c
 @@ -76,7 +76,10 @@
  	 and the last byte is filled with NUL.  So we can simply
  	 use that buffer.  */
-       assert (len > 0);
+       assert (len >= 0);
 -      assert (malloc_usable_size (netgrp->data) >= len + 1);
 +      /* Call to malloc_usable_size disabled, this breaks if applications
 +	 redefine malloc/free with a different implementation.
diff --git a/debian/patches/series b/debian/patches/series
index 1efbe67..75b0b48 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -49,6 +49,7 @@ localedata/reverted-for-etch.diff -p1
 #alpha/submitted-pic.diff -p0	# g: suspended
 alpha/cvs-gcc4-profile.diff -p0
 alpha/local-gcc4.1.diff -p0
+alpha/local-waitpid-not-cancel.diff -p0
 alpha/submitted-xstat.diff -p0
 
 amd64/local-biarch.diff -p1
@@ -140,6 +141,7 @@ any/cvs-errlist.diff -p0
 any/cvs-futimes.diff -p0
 any/cvs-getcwd_c.diff -p1
 any/cvs-itoa-c.diff -p1
+any/cvs-nss_nis_setnetgrent.diff -p0
 any/cvs-nfs_h.diff -p0
 any/cvs-path_log.diff -p0
 any/cvs-regcomp_c.diff -p1
@@ -182,7 +184,12 @@ any/local-tcsetaddr.diff -p1
 any/local-ttyname-devfs.diff -p0
 any/local-version-sanity.diff -p1
 any/submitted-eh-frame-terminator.diff -p1
+any/submitted-gethostbyname_r.diff -p0
 any/submitted-nis-netgrp.diff 
 any/submitted-strfmon.diff
 any/cvs-sunrpc-xdrmem_setpos.diff
 any/cvs-getent-wrong-struct-size.diff -p0
+any/cvs-nscd-free.diff -p1
+any/cvs-sunrpc-64bits-svc_getreqset.diff -p0
+any/cvs-vfprintf-stack-smashing.diff
+any/cvs-getnetgrent_r-memory-leak.diff
diff --git a/debian/rules.d/debhelper.mk b/debian/rules.d/debhelper.mk
index e2e57e4..ca70152 100644
--- a/debian/rules.d/debhelper.mk
+++ b/debian/rules.d/debhelper.mk
@@ -67,6 +67,10 @@ $(patsubst %,$(stamp)binaryinst_%,$(DEB_ARCH_REGULAR_PACKAGES) $(DEB_INDEP_REGUL
 	dh_installinit -p$(curpass)
 	dh_installdocs -p$(curpass) 
 	dh_link -p$(curpass)
+	set -e; for file in `find debian/bug -name '$(curpass).*'`; do \
+	    dh_installdirs -p$(curpass) usr/share/bug;                 \
+	    dh_install -p$(curpass) $$file usr/share/bug;              \
+	done
 
 	# extra_debhelper_pkg_install is used for debhelper.mk only.
 	# when you want to install extra packages, use extra_pkg_install.
@@ -125,7 +129,9 @@ endif
 	dh_makeshlibs -p$(curpass) -V "$(call xx,shlib_dep)"
 
 	dh_installdeb -p$(curpass)
-	# dh_shlibdeps -p$(curpass)
+	if [ $(curpass) = nscd ] ; then \
+		dh_shlibdeps -p$(curpass) ; \
+	fi
 	dh_gencontrol -p$(curpass) -- $($(curpass)_control_flags)
 	dh_md5sums -p$(curpass)
 	dh_builddeb -p$(curpass)
