https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4d376dfd6487d63c3374f62d75dcb82a4563aac3

commit 4d376dfd6487d63c3374f62d75dcb82a4563aac3
Author:     Eric Kohl <[email protected]>
AuthorDate: Sat Dec 14 20:09:27 2024 +0100
Commit:     Eric Kohl <[email protected]>
CommitDate: Sat Dec 14 20:09:27 2024 +0100

    [SETUPAPI] CM_Set_Class_Registry_PropertyW: Do not convert SD if ulLength 
is 0
---
 dll/win32/setupapi/cfgmgr.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/dll/win32/setupapi/cfgmgr.c b/dll/win32/setupapi/cfgmgr.c
index 0444611c184..f0b49db3fe9 100644
--- a/dll/win32/setupapi/cfgmgr.c
+++ b/dll/win32/setupapi/cfgmgr.c
@@ -7975,17 +7975,21 @@ CM_Set_Class_Registry_PropertyW(
 
     if (ulProperty == CM_CRP_SECURITY_SDS)
     {
-        if 
(!ConvertStringSecurityDescriptorToSecurityDescriptorW((LPCWSTR)Buffer,
-                                                                  
SDDL_REVISION_1,
-                                                                  
&pSecurityDescriptor,
-                                                                  
&SecurityDescriptorSize))
+        if (ulLength != 0)
         {
-            ERR("ConvertStringSecurityDescriptorToSecurityDescriptorW() failed 
(Error %lu)\n", GetLastError());
-            return CR_INVALID_DATA;
+            if 
(!ConvertStringSecurityDescriptorToSecurityDescriptorW((LPCWSTR)Buffer,
+                                                                      
SDDL_REVISION_1,
+                                                                      
&pSecurityDescriptor,
+                                                                      
&SecurityDescriptorSize))
+            {
+                ERR("ConvertStringSecurityDescriptorToSecurityDescriptorW() 
failed (Error %lu)\n", GetLastError());
+                return CR_INVALID_DATA;
+            }
+
+            Buffer = (PCVOID)pSecurityDescriptor;
+            ulLength = SecurityDescriptorSize;
         }
 
-        Buffer = (PCVOID)pSecurityDescriptor;
-        ulLength = SecurityDescriptorSize;
         ulProperty = CM_CRP_SECURITY;
         ulType = REG_BINARY;
     }

Reply via email to