From 4d376dfd6487d63c3374f62d75dcb82a4563aac3 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sat, 14 Dec 2024 20:09:27 +0100 Subject: [PATCH] [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; }