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 invalid port deallocation in `symlink'


Hello,

Currently, running âln -s foo barâ on a read-only file system leads to
an invalid port deallocation.

This patch fixes that.

Thanks,
Ludoâ.

2012-03-17  Ludovic CourtÃs  <ludo@gnu.org>

	* sysdeps/mach/hurd/symlink.c (__symlink): Deallocate NODE only
	when it is non-null.

diff --git a/sysdeps/mach/hurd/symlink.c b/sysdeps/mach/hurd/symlink.c
index 857e236..4a4e61f 100644
--- a/sysdeps/mach/hurd/symlink.c
+++ b/sysdeps/mach/hurd/symlink.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 12 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -44,6 +44,7 @@ __symlink (from, to)
     return -1;
 
   /* Create a new, unlinked node in the target directory.  */
+  node = MACH_PORT_NULL;
   err = __dir_mkfile (dir, O_WRITE, 0777 & ~_hurd_umask, &node);
 
   if (! err)
@@ -59,7 +60,9 @@ __symlink (from, to)
     err = __dir_link (dir, node, name, 1);
 
   __mach_port_deallocate (__mach_task_self (), dir);
-  __mach_port_deallocate (__mach_task_self (), node);
+
+  if (node != MACH_PORT_NULL)
+    __mach_port_deallocate (__mach_task_self (), node);
 
   if (err)
     return __hurd_fail (err);

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