about summary refs log tree commit diff
path: root/sysdeps/mach/hurd/spawni.c
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2018-11-10 11:20:12 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2018-11-10 11:20:12 +0000
commit7fa495cdf750c257ed897eca189aabc3a62d5f2b (patch)
tree12ecb16594bec98161c7517953ecbf2dba071aff /sysdeps/mach/hurd/spawni.c
parent434c34bd8e3fe5b5dd951c74aef3f0b71d0e08c2 (diff)
downloadglibc-7fa495cdf750c257ed897eca189aabc3a62d5f2b.tar.gz
glibc-7fa495cdf750c257ed897eca189aabc3a62d5f2b.tar.xz
glibc-7fa495cdf750c257ed897eca189aabc3a62d5f2b.zip
Hurd: Fix ulinks in fd table reallocation
	* hurd/hurd/userlink.h (_hurd_userlink_move): New function.
	* hurd/hurd/port.h (_hurd_port_move): New function.
	* sysdeps/mach/hurd/spawni.c (NEW_ULINK_TABLE): New macro.
	(EXPAND_DTABLE): Use NEW_ULINK_TABLE macro for ulink_dtable.
Diffstat (limited to 'sysdeps/mach/hurd/spawni.c')
-rw-r--r--sysdeps/mach/hurd/spawni.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/sysdeps/mach/hurd/spawni.c b/sysdeps/mach/hurd/spawni.c
index 4fd0cdd520..c08f2a5b5a 100644
--- a/sysdeps/mach/hurd/spawni.c
+++ b/sysdeps/mach/hurd/spawni.c
@@ -457,7 +457,7 @@ __spawni (pid_t *pid, const char *file,
 	    {								      \
 	      /* We need to expand the dtable for the child.  */	      \
 	      NEW_TABLE (dtable, newfd);				      \
-	      NEW_TABLE (ulink_dtable, newfd);				      \
+	      NEW_ULINK_TABLE (ulink_dtable, newfd);			      \
 	      NEW_TABLE (dtable_cells, newfd);				      \
 	      dtablesize = newfd + 1;					      \
 	    }								      \
@@ -468,6 +468,16 @@ __spawni (pid_t *pid, const char *file,
   memcpy (new_##x, x, dtablesize * sizeof (x[0]));			      \
   memset (&new_##x[dtablesize], 0, (newfd + 1 - dtablesize) * sizeof (x[0])); \
   x = new_##x; } while (0)
+#define NEW_ULINK_TABLE(x, newfd) \
+  do { __typeof (x) new_##x = __alloca ((newfd + 1) * sizeof (x[0]));	      \
+  unsigned i;								      \
+  for (i = 0; i < dtablesize; i++)					      \
+    if (dtable_cells[i] != NULL)					      \
+      _hurd_port_move (dtable_cells[i], &new_##x[i], &x[i]);		      \
+    else								      \
+      memset(&new_##x[i], 0, sizeof(new_##x[i]));			      \
+  memset (&new_##x[dtablesize], 0, (newfd + 1 - dtablesize) * sizeof (x[0])); \
+  x = new_##x; } while (0)
 
 	struct __spawn_action *action = &file_actions->__actions[i];