wrowe 01/06/10 12:34:27
Modified: user/win32 userinfo.c
Log:
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.
Revision Changes Path
1.10 +15 -10 apr/user/win32/userinfo.c
Index: userinfo.c
===================================================================
RCS file: /home/cvs/apr/user/win32/userinfo.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- userinfo.c 2001/06/10 17:23:00 1.9
+++ userinfo.c 2001/06/10 19:34:27 1.10
@@ -78,9 +78,9 @@
* 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 @@
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 @@
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();
}