aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2004-02-11 17:54:34 +0000
committerCorinna Vinschen <corinna@vinschen.de>2004-02-11 17:54:34 +0000
commit897c785600c7526ca2e72a2fc4b18ede664bd5c8 (patch)
tree7cd6bb55fb091507a2e31a79b9b8852331a6360b
parent6c6a0522304ccad18f938119e27a8a3c2a14205f (diff)
downloadnewlib-897c785600c7526ca2e72a2fc4b18ede664bd5c8.zip
newlib-897c785600c7526ca2e72a2fc4b18ede664bd5c8.tar.gz
newlib-897c785600c7526ca2e72a2fc4b18ede664bd5c8.tar.bz2
* security.cc (get_nt_object_attribute): Fix error handling.
-rw-r--r--winsup/cygwin/ChangeLog4
-rw-r--r--winsup/cygwin/security.cc58
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 <corinna@vinschen.de>
+
+ * security.cc (get_nt_object_attribute): Fix error handling.
+
2004-02-09 Ralf Habacker <ralf.habacker@freenet.de>
* 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);
}
}