summaryrefslogtreecommitdiff
path: root/user
diff options
context:
space:
mode:
authorwrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68>2001-06-10 19:34:27 +0000
committerwrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68>2001-06-10 19:34:27 +0000
commit09858c6e3e537dfa0259c6b7805444e8bca432b0 (patch)
treedf276ae5032c2da04614c423aba94b9656092ea9 /user
parent24f50a635232e17eee44a872313512117e7c4206 (diff)
downloadlibapr-09858c6e3e537dfa0259c6b7805444e8bca432b0.tar.gz
Solve two flukes. First, I mis-constructed the sid authority. Second,
if the LookupAccountName call has to resolve the domain (e.g., lookup user joe), it must have a domain buffer or we segfault. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@61747 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'user')
-rw-r--r--user/win32/userinfo.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/user/win32/userinfo.c b/user/win32/userinfo.c
index 92f304b4c..1fe632fae 100644
--- a/user/win32/userinfo.c
+++ b/user/win32/userinfo.c
@@ -78,9 +78,9 @@ void get_sid_string(char *buf, int blen, apr_uid_t id)
* and NT records the value as hex if the value is > 2^32.)
*/
psia = GetSidIdentifierAuthority(id);
- nsa = (DWORD)psia->Value[5] + (DWORD)psia->Value[4] << 8 +
- (DWORD)psia->Value[3] << 16 + (DWORD)psia->Value[2] << 24;
- sa = (DWORD)psia->Value[1] + (DWORD)psia->Value[0] << 8;
+ nsa = (DWORD)(psia->Value[5]) + ((DWORD)(psia->Value[4]) << 8)
+ + ((DWORD)(psia->Value[3])) << 16 + ((DWORD)(psia->Value[2]) << 24);
+ sa = (DWORD)(psia->Value[1]) + ((DWORD)(psia->Value[0]) << 8);
if (sa) {
slen = apr_snprintf(buf, blen, "S-%lu-0x%04x%08x",
SID_REVISION, sa, nsa);
@@ -190,8 +190,11 @@ APR_DECLARE(apr_status_t) apr_get_userid(apr_uid_t *uid, apr_gid_t *gid,
const char *username, apr_pool_t *p)
{
SID_NAME_USE sidtype;
- char *domain = NULL;
- DWORD sidlen, rv;
+ char anydomain[256];
+ char *domain;
+ DWORD sidlen = 0;
+ DWORD domlen = sizeof(anydomain);
+ DWORD rv;
char *pos;
if (pos = strchr(username, '/')) {
@@ -202,19 +205,21 @@ APR_DECLARE(apr_status_t) apr_get_userid(apr_uid_t *uid, apr_gid_t *gid,
domain = apr_pstrndup(p, username, pos - username);
username = pos + 1;
}
+ else {
+ domain = NULL;
+ }
/* Get nothing on the first pass ... need to size the sid buffer
*/
- sidlen = LookupAccountName(domain, username, NULL, NULL,
- NULL, NULL, &sidtype);
+ rv = LookupAccountName(domain, username, domain, &sidlen,
+ anydomain, &domlen, &sidtype);
if (sidlen) {
/* Give it back on the second pass
*/
*uid = apr_palloc(p, sidlen);
+ domlen = sizeof(anydomain);
rv = LookupAccountName(domain, username, *uid, &sidlen,
- NULL, NULL, &sidtype);
+ anydomain, &domlen, &sidtype);
}
- else
- rv = 0; /* Quiet the compiler */
if (!sidlen || !rv) {
return apr_get_os_error();
}