[ros-diffs] [ekohl] 51172: [SERVICES] ScmWriteDependencies: - Fixed an off-by-one bug. This bug caused a wrong calculation of the 'DependOnGroup' value data length. Group dependencies were not written properly...

ekohl at svn.reactos.org ekohl at svn.reactos.org
Sun Mar 27 13:12:12 UTC 2011


Author: ekohl
Date: Sun Mar 27 13:12:12 2011
New Revision: 51172

URL: http://svn.reactos.org/svn/reactos?rev=51172&view=rev
Log:
[SERVICES]
ScmWriteDependencies:
- Fixed an off-by-one bug. This bug caused a wrong calculation of the 'DependOnGroup' value data length. Group dependencies were not written properly to the registry.

- Write 'DependOnService' and 'DependOnService' values to the registry only if the dependency strings are not empty. Delete a value if the corresponding dependency string is empty.

This fixes another winetest.

Modified:
    trunk/reactos/base/system/services/config.c

Modified: trunk/reactos/base/system/services/config.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/config.c?rev=51172&r1=51171&r2=51172&view=diff
==============================================================================
--- trunk/reactos/base/system/services/config.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/services/config.c [iso-8859-1] Sun Mar 27 13:12:12 2011
@@ -125,7 +125,7 @@
         lpDst = lpGroupDeps;
         while (*lpSrc != 0)
         {
-            dwLength = wcslen(lpSrc);
+            dwLength = wcslen(lpSrc) + 1;
             if (*lpSrc == SC_GROUP_IDENTIFIERW)
             {
                 lpSrc++;
@@ -157,21 +157,37 @@
         *lpDst = 0;
         dwServiceLength++;
 
-        dwError = RegSetValueExW(hServiceKey,
-                                 L"DependOnGroup",
-                                 0,
-                                 REG_MULTI_SZ,
-                                 (LPBYTE)lpGroupDeps,
-                                 dwGroupLength * sizeof(WCHAR));
-
-        if (dwError == ERROR_SUCCESS)
+        if (dwGroupLength > 1)
         {
             dwError = RegSetValueExW(hServiceKey,
-                                     L"DependOnService",
+                                     L"DependOnGroup",
                                      0,
                                      REG_MULTI_SZ,
-                                     (LPBYTE)lpServiceDeps,
-                                     dwServiceLength * sizeof(WCHAR));
+                                     (LPBYTE)lpGroupDeps,
+                                     dwGroupLength * sizeof(WCHAR));
+        }
+        else
+        {
+            RegDeleteValueW(hServiceKey,
+                            L"DependOnGroup");
+        }
+
+        if (dwError == ERROR_SUCCESS)
+        {
+            if (dwServiceLength > 1)
+            {
+                dwError = RegSetValueExW(hServiceKey,
+                                         L"DependOnService",
+                                         0,
+                                         REG_MULTI_SZ,
+                                         (LPBYTE)lpServiceDeps,
+                                         dwServiceLength * sizeof(WCHAR));
+            }
+            else
+            {
+                RegDeleteValueW(hServiceKey,
+                                L"DependOnService");
+            }
         }
 
         HeapFree(GetProcessHeap(), 0, lpGroupDeps);




More information about the Ros-diffs mailing list