diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2011-02-15 17:44:11 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2011-02-15 17:44:11 +0300 |
commit | fe222f22104df2192684f04fab0847831d114705 (patch) | |
tree | d96a9989cd7f0b34ad533061613ead2fdf5074c9 | |
parent | c48947b454fec1bc774059562c217f179e32c0e5 (diff) |
* fhandler_procsys.cc (fhandler_procsys::opendir): Avoid SEGV if
opening object directory fails.
* fhandler_virtual.cc (fhandler_virtual::opendir): Don't leak memory.
-rw-r--r-- | winsup/cygwin/ChangeLog | 6 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_procsys.cc | 10 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_virtual.cc | 3 |
3 files changed, 14 insertions, 5 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 4efbd2244..3d0880de2 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,11 @@ 2011-02-15 Corinna Vinschen <corinna@vinschen.de> + * fhandler_procsys.cc (fhandler_procsys::opendir): Avoid SEGV if + opening object directory fails. + * fhandler_virtual.cc (fhandler_virtual::opendir): Don't leak memory. + +2011-02-15 Corinna Vinschen <corinna@vinschen.de> + * fhandler_disk_file.cc (fhandler_disk_file::readdir_helper): Don't append slash if there is one already. diff --git a/winsup/cygwin/fhandler_procsys.cc b/winsup/cygwin/fhandler_procsys.cc index 0f4cc1747..6c91a2f9c 100644 --- a/winsup/cygwin/fhandler_procsys.cc +++ b/winsup/cygwin/fhandler_procsys.cc @@ -1,6 +1,6 @@ /* fhandler_procsys.cc: fhandler for native NT namespace. - Copyright 2010 Red Hat, Inc. + Copyright 2010, 2011 Red Hat, Inc. This file is part of Cygwin. @@ -245,18 +245,20 @@ fhandler_procsys::opendir (int fd) OBJECT_ATTRIBUTES attr; NTSTATUS status; HANDLE h; - DIR *dir = fhandler_virtual::opendir (fd); + DIR *dir; mk_unicode_path (&path); InitializeObjectAttributes (&attr, &path, OBJ_CASE_INSENSITIVE, NULL, NULL); status = NtOpenDirectoryObject (&h, DIRECTORY_QUERY, &attr); if (!NT_SUCCESS (status)) { - free (dir); __seterrno_from_nt_status (status); return NULL; } - dir->__handle = h; + if (!(dir = fhandler_virtual::opendir (fd))) + NtClose (h); + else + dir->__handle = h; return dir; } diff --git a/winsup/cygwin/fhandler_virtual.cc b/winsup/cygwin/fhandler_virtual.cc index 6d515a3a7..1c4e71008 100644 --- a/winsup/cygwin/fhandler_virtual.cc +++ b/winsup/cygwin/fhandler_virtual.cc @@ -1,6 +1,6 @@ /* fhandler_virtual.cc: base fhandler class for virtual filesystems - Copyright 2002, 2003, 2004, 2005, 2007, 2008, 2009 Red Hat, Inc. + Copyright 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011 Red Hat, Inc. This file is part of Cygwin. @@ -59,6 +59,7 @@ fhandler_virtual::opendir (int fd) else if ((dir->__d_dirent = (struct dirent *) malloc (sizeof (struct dirent))) == NULL) { + free (dir->__d_dirname); free (dir); set_errno (ENOMEM); } |