[ADVAPI32]
authorThomas Faber <thomas.faber@reactos.org>
Fri, 24 Aug 2012 12:52:29 +0000 (12:52 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Fri, 24 Aug 2012 12:52:29 +0000 (12:52 +0000)
- Correctly handle NULL passwords for services. Patch by Hermès Bélusca. Fixes crash in advapi32_winetest:service. See bug 7239, bug 7293.

svn path=/trunk/; revision=57150

reactos/dll/win32/advapi32/service/scm.c

index 97fcf8e..0fcee5b 100644 (file)
@@ -309,7 +309,7 @@ ChangeServiceConfigA(SC_HANDLE hService,
 
     /* FIXME: Encrypt the password */
     lpEncryptedPassword = (LPBYTE)lpPassword;
-    dwPasswordLength = (strlen(lpPassword) + 1) * sizeof(CHAR);
+    dwPasswordLength = (lpPassword ? (strlen(lpPassword) + 1) * sizeof(CHAR) : 0);
 
     RpcTryExcept
     {
@@ -387,7 +387,7 @@ ChangeServiceConfigW(SC_HANDLE hService,
 
     /* FIXME: Encrypt the password */
     lpEncryptedPassword = (LPBYTE)lpPassword;
-    dwPasswordLength = (wcslen(lpPassword) + 1) * sizeof(WCHAR);
+    dwPasswordLength = (lpPassword ? (wcslen(lpPassword) + 1) * sizeof(WCHAR) : 0);
 
     RpcTryExcept
     {
@@ -577,7 +577,7 @@ CreateServiceA(SC_HANDLE hSCManager,
 
     /* FIXME: Encrypt the password */
     lpEncryptedPassword = (LPBYTE)lpPassword;
-    dwPasswordLength = (strlen(lpPassword) + 1) * sizeof(CHAR);
+    dwPasswordLength = (lpPassword ? (strlen(lpPassword) + 1) * sizeof(CHAR) : 0);
 
     RpcTryExcept
     {
@@ -671,7 +671,7 @@ CreateServiceW(SC_HANDLE hSCManager,
 
     /* FIXME: Encrypt the password */
     lpEncryptedPassword = (LPBYTE)lpPassword;
-    dwPasswordLength = (wcslen(lpPassword) + 1) * sizeof(WCHAR);
+    dwPasswordLength = (lpPassword ? (wcslen(lpPassword) + 1) * sizeof(WCHAR) : 0);
 
     RpcTryExcept
     {