From 897c785600c7526ca2e72a2fc4b18ede664bd5c8 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Wed, 11 Feb 2004 17:54:34 +0000 Subject: * security.cc (get_nt_object_attribute): Fix error handling. --- winsup/cygwin/ChangeLog | 4 ++++ winsup/cygwin/security.cc | 58 ++++++++++++++++++++--------------------------- 2 files changed, 29 insertions(+), 33 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 7de0793..852c183 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +2004-02-11 Corinna Vinschen + + * security.cc (get_nt_object_attribute): Fix error handling. + 2004-02-09 Ralf Habacker * fhandler_socket.cc (fhandler_socket::ioctl): Add FIONREAD handling. diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc index f54c33d..8195298 100644 --- a/winsup/cygwin/security.cc +++ b/winsup/cygwin/security.cc @@ -1407,48 +1407,40 @@ get_nt_object_attribute (HANDLE handle, SE_OBJECT_TYPE object_type, { security_descriptor sd; PSECURITY_DESCRIPTOR psd = NULL; + LONG ret; if (object_type == SE_REGISTRY_KEY) { /* use different code for registry handles, for performance reasons */ DWORD len = 0; - if (RegGetKeySecurity ((HKEY) handle, - DACL_SECURITY_INFORMATION - | GROUP_SECURITY_INFORMATION - | OWNER_SECURITY_INFORMATION, - sd, &len) != ERROR_INSUFFICIENT_BUFFER) - { - __seterrno (); - debug_printf ("RegGetKeySecurity %E"); - } - if (!sd.malloc (len)) + if ((ret = RegGetKeySecurity ((HKEY) handle, + DACL_SECURITY_INFORMATION + | GROUP_SECURITY_INFORMATION + | OWNER_SECURITY_INFORMATION, + sd, &len)) != ERROR_INSUFFICIENT_BUFFER) + __seterrno_from_win_error (ret); + else if (!sd.malloc (len)) set_errno (ENOMEM); - else if (RegGetKeySecurity ((HKEY) handle, - DACL_SECURITY_INFORMATION - | GROUP_SECURITY_INFORMATION - | OWNER_SECURITY_INFORMATION, - sd, &len) != ERROR_SUCCESS) - { - __seterrno (); - debug_printf ("RegGetKeySecurity %E"); - } - get_info_from_sd (sd, attribute, uidret, gidret); - } + else if ((ret = RegGetKeySecurity ((HKEY) handle, + DACL_SECURITY_INFORMATION + | GROUP_SECURITY_INFORMATION + | OWNER_SECURITY_INFORMATION, + sd, &len)) != ERROR_SUCCESS) + __seterrno_from_win_error (ret); + else + psd = sd; + get_info_from_sd (psd, attribute, uidret, gidret); + } + else if ((ret = GetSecurityInfo (handle, object_type, + DACL_SECURITY_INFORMATION + | GROUP_SECURITY_INFORMATION + | OWNER_SECURITY_INFORMATION, + NULL, NULL, NULL, NULL, &psd))) + __seterrno_from_win_error (ret); else { - if (ERROR_SUCCESS != GetSecurityInfo (handle, object_type, - DACL_SECURITY_INFORMATION | - GROUP_SECURITY_INFORMATION | - OWNER_SECURITY_INFORMATION, - NULL, NULL, NULL, NULL, &psd)) - { - __seterrno (); - debug_printf ("GetSecurityInfo %E"); - psd = NULL; - } get_info_from_sd (psd, attribute, uidret, gidret); - if (psd) - LocalFree (psd); + LocalFree (psd); } } -- cgit v1.1