diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2006-10-22 18:57:43 +0400 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2006-10-22 18:57:43 +0400 |
commit | 2be593d961e3ccd21a7a19b5a0b716e43d0137dc (patch) | |
tree | f0a707df944d7f8ef6c067627209d99dc9ad7907 /winsup/cygwin/sec_helper.cc | |
parent | 2b26c2fc410ad29dbc2e906e98845c06db79e726 (diff) |
* external.cc (cygwin_internal): Use security_descriptor::copy method.
* sec_helper.cc (security_descriptor::malloc): Use own free method.
Set type.
(security_descriptor::realloc): Handle the case that psd has been
allocated using LocalAlloc. Set type.
(security_descriptor::free): Ditto.
* security.cc (get_nt_attribute): Remove.
(get_reg_security): Remove.
(get_nt_object_security): Use GetSecurityInfo which handles all
securable objects.
(get_nt_object_attribute): Remove.
(get_object_attribute): Call get_nt_object_security instead of
get_nt_object_attribute.
(get_file_attribute): Ditto.
(check_registry_access): Call get_nt_object_security instead of
get_reg_security.
* security.h (cygpsid::operator PSID): Make method const, not the
result.
(class security_descriptor): Add type member. Accomodate throughout.
(security_descriptor::copy): New method.
(security_descriptor::operator PSECURITY_DESCRIPTOR *): New operator.
Diffstat (limited to 'winsup/cygwin/sec_helper.cc')
-rw-r--r-- | winsup/cygwin/sec_helper.cc | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/winsup/cygwin/sec_helper.cc b/winsup/cygwin/sec_helper.cc index a32dcb8f5..002abf48b 100644 --- a/winsup/cygwin/sec_helper.cc +++ b/winsup/cygwin/sec_helper.cc @@ -224,20 +224,37 @@ get_sids_info (cygpsid owner_sid, cygpsid group_sid, __uid32_t * uidret, __gid32 PSECURITY_DESCRIPTOR security_descriptor::malloc (size_t nsize) { - if (psd) - ::free (psd); - psd = (PSECURITY_DESCRIPTOR) ::malloc (nsize); - sd_size = psd ? nsize : 0; + free (); + if ((psd = (PSECURITY_DESCRIPTOR) ::malloc (nsize))) + { + sd_size = nsize; + type = malloced; + } return psd; } PSECURITY_DESCRIPTOR security_descriptor::realloc (size_t nsize) { - PSECURITY_DESCRIPTOR tmp = (PSECURITY_DESCRIPTOR) ::realloc (psd, nsize); - if (!tmp) - return NULL; + PSECURITY_DESCRIPTOR tmp; + + if (type == malloced) + { + if (!(tmp = (PSECURITY_DESCRIPTOR) ::realloc (psd, nsize))) + return NULL; + } + else + { + if (!(tmp = (PSECURITY_DESCRIPTOR) ::malloc (nsize))) + return NULL; + if (psd) + { + memcpy (tmp, psd, LocalSize (psd)); + LocalFree (psd); + } + } sd_size = nsize; + type = malloced; return psd = tmp; } @@ -245,9 +262,15 @@ void security_descriptor::free () { if (psd) - ::free (psd); + { + if (type == local_alloced) + LocalFree (psd); + else + ::free (psd); + } psd = NULL; sd_size = 0; + type = local_alloced; } #if 0 // unused |