diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2004-02-11 17:54:34 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2004-02-11 17:54:34 +0000 |
commit | 897c785600c7526ca2e72a2fc4b18ede664bd5c8 (patch) | |
tree | 7cd6bb55fb091507a2e31a79b9b8852331a6360b /winsup/cygwin/security.cc | |
parent | 6c6a0522304ccad18f938119e27a8a3c2a14205f (diff) | |
download | newlib-897c785600c7526ca2e72a2fc4b18ede664bd5c8.zip newlib-897c785600c7526ca2e72a2fc4b18ede664bd5c8.tar.gz newlib-897c785600c7526ca2e72a2fc4b18ede664bd5c8.tar.bz2 |
* security.cc (get_nt_object_attribute): Fix error handling.
Diffstat (limited to 'winsup/cygwin/security.cc')
-rw-r--r-- | winsup/cygwin/security.cc | 58 |
1 files changed, 25 insertions, 33 deletions
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); } } |