This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH,HURD] Fix __dup2 _hurd_dtable_lock usage.


Hello,

While checking the usage of _hurd_dtable_lock, I noticed that __dup2
does not lock/unlock it properly, the patch below should fix it.

Samuel

2009-01-07  Samuel Thibault  <samuel.thibault@ens-lyon.org>

	* sysdeps/mach/hurd/dup2.c (__dup2): Lock _hurd_dtable_lock
	before checking for _hurd_dtable_size.  Unlock it only when it
	has been locked.

Index: sysdeps/mach/hurd/dup2.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/mach/hurd/dup2.c,v
retrieving revision 1.20
diff -u -p -r1.20 dup2.c
--- sysdeps/mach/hurd/dup2.c	3 Aug 2002 06:46:57 -0000	1.20
+++ sysdeps/mach/hurd/dup2.c	7 Jan 2009 01:54:56 -0000
@@ -68,6 +68,8 @@ __dup2 (fd, fd2)
 	  /* Get a hold of the destination descriptor.  */
 	  struct hurd_fd *d2;
 
+	  __mutex_lock (&_hurd_dtable_lock);
+
 	  if (fd2 >= _hurd_dtablesize)
 	    {
 	      /* The table is not large enough to hold the destination
@@ -118,8 +120,8 @@ __dup2 (fd, fd2)
 	      _hurd_port_set (&d2->ctty, ctty);
 	      _hurd_port_locked_set (&d2->port, port); /* Unlocks D2.  */
 	    }
+	  __mutex_unlock (&_hurd_dtable_lock);
 	}
-      __mutex_unlock (&_hurd_dtable_lock);
 
       _hurd_port_free (&d->port, &ulink, port);
       if (ctty != MACH_PORT_NULL)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]