diff options
author | mturk <mturk@13f79535-47bb-0310-9956-ffa450edef68> | 2005-01-17 10:39:21 +0000 |
---|---|---|
committer | mturk <mturk@13f79535-47bb-0310-9956-ffa450edef68> | 2005-01-17 10:39:21 +0000 |
commit | ef7715bf403829c89f1faa896fab8cdfff9befaf (patch) | |
tree | 5a1f1712cfa99b04365e8365c5b8e7cfbca59f6d | |
parent | 1819a003095e99c533f3e0003352cef0d88cd0c3 (diff) | |
download | libapr-ef7715bf403829c89f1faa896fab8cdfff9befaf.tar.gz |
Use zero length password if supplied password is NULL.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@125406 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | threadproc/win32/proc.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/threadproc/win32/proc.c b/threadproc/win32/proc.c index 069a8e409..7ff680f8c 100644 --- a/threadproc/win32/proc.c +++ b/threadproc/win32/proc.c @@ -247,29 +247,32 @@ APR_DECLARE(apr_status_t) apr_procattr_user_set(apr_procattr_t *attr, } return rv; } - len = strlen(password) + 1; - wlen = len; - wpassword = apr_palloc(attr->pool, wlen * sizeof(apr_wchar_t)); - if ((rv = apr_conv_utf8_to_ucs2(password, &len, wpassword, &wlen)) - != APR_SUCCESS) { - if (attr->errfn) { - attr->errfn(attr->pool, rv, - apr_pstrcat(attr->pool, + if (password) { + len = strlen(password) + 1; + wlen = len; + wpassword = apr_palloc(attr->pool, wlen * sizeof(apr_wchar_t)); + if ((rv = apr_conv_utf8_to_ucs2(password, &len, wpassword, &wlen)) + != APR_SUCCESS) { + if (attr->errfn) { + attr->errfn(attr->pool, rv, + apr_pstrcat(attr->pool, "utf8 to ucs2 conversion failed" " on password: ", password, NULL)); + } + return rv; } - return rv; } if (!LogonUserW(wusername, NULL, - wpassword, + wpassword ? wpassword : L"", LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, &user)) { /* Logon Failed */ return apr_get_os_error(); - } - memset(wpassword, 0, wlen * sizeof(apr_wchar_t)); + } + if (wpassword) + memset(wpassword, 0, wlen * sizeof(apr_wchar_t)); /* Get the primary token for user */ if (!DuplicateTokenEx(user, TOKEN_QUERY | TOKEN_DUPLICATE | TOKEN_ASSIGN_PRIMARY, |