From e70ffcb0fa9a63e7befc3e513944aeb19d2e4748 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 22 Dec 2009 11:47:13 -0800 Subject: [PATCH 1/2] Hurd: Fix spurious mach_port_deallocate in getcwd. --- ChangeLog | 5 +++++ sysdeps/mach/hurd/getcwd.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 07a707b051..3ff2684f56 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-12-20 Samuel Thibault + + * sysdeps/mach/hurd/getcwd.c (cleanup): Do not call + __mach_port_deallocate on rootdevid. + 2009-12-17 Martin Schwidefsky * sysdeps/s390/s390-32/dl-machine.h (elf_machine_rela): Handle diff --git a/sysdeps/mach/hurd/getcwd.c b/sysdeps/mach/hurd/getcwd.c index 7e07e6b404..7da677eec9 100644 --- a/sysdeps/mach/hurd/getcwd.c +++ b/sysdeps/mach/hurd/getcwd.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1991,92,93,94,95,96,97,98,2002,04 Free Software Foundation, Inc. +/* Copyright (C) 1991,92,93,94,95,96,97,98,2002,2004,2009 + 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 @@ -60,7 +61,6 @@ _hurd_canonicalize_directory_name_internal (file_t thisdir, __mach_port_deallocate (__mach_task_self (), thisid); __mach_port_deallocate (__mach_task_self (), thisdevid); __mach_port_deallocate (__mach_task_self (), rootid); - __mach_port_deallocate (__mach_task_self (), rootdevid); if (dirbuf != NULL) __vm_deallocate (__mach_task_self (), From e87e2f48effefe5e70a9a21bc13d7187608d0365 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 22 Dec 2009 11:51:44 -0800 Subject: [PATCH 2/2] Hurd: Fix possibly uninitialized variable in _hurd_locked_install_cttyid. --- ChangeLog | 5 +++++ hurd/hurdioctl.c | 24 ++++++++++-------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3ff2684f56..aba0d71b28 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-12-22 Samuel Thibault + + * hurd/hurdioctl.c (_hurd_locked_install_cttyid): Set newctty to + MACH_PORT_NULL when id != cttyid. + 2009-12-20 Samuel Thibault * sysdeps/mach/hurd/getcwd.c (cleanup): Do not call diff --git a/hurd/hurdioctl.c b/hurd/hurdioctl.c index 96d910ba1a..7c689841ca 100644 --- a/hurd/hurdioctl.c +++ b/hurd/hurdioctl.c @@ -1,5 +1,6 @@ /* ioctl commands which must be done in the C library. - Copyright (C) 1994,95,96,97,99,2001,02 Free Software Foundation, Inc. + Copyright (C) 1994,95,96,97,99,2001,2002,2009 + 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 @@ -169,33 +170,28 @@ _hurd_locked_install_cttyid (mach_port_t cttyid) for (i = 0; i < _hurd_dtablesize; ++i) { struct hurd_fd *const d = _hurd_dtable[i]; - mach_port_t newctty; + mach_port_t newctty = MACH_PORT_NULL; if (d == NULL) /* Nothing to do for an unused descriptor cell. */ continue; - if (cttyid == MACH_PORT_NULL) - /* We now have no controlling tty at all. */ - newctty = MACH_PORT_NULL; - else + if (cttyid != MACH_PORT_NULL) + /* We do have some controlling tty. */ HURD_PORT_USE (&d->port, ({ mach_port_t id; /* Get the io object's cttyid port. */ if (! __term_getctty (port, &id)) { - if (id == cttyid && /* Is it ours? */ + if (id == cttyid /* Is it ours? */ /* Get the ctty io port. */ - __term_open_ctty (port, - _hurd_pid, _hurd_pgrp, - &newctty)) + && __term_open_ctty (port, + _hurd_pid, _hurd_pgrp, + &newctty)) /* XXX it is our ctty but the call failed? */ newctty = MACH_PORT_NULL; - __mach_port_deallocate - (__mach_task_self (), (mach_port_t) id); + __mach_port_deallocate (__mach_task_self (), id); } - else - newctty = MACH_PORT_NULL; 0; }));