]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
examples:winexe: Fully initialize EXPLICIT_ACCESS
authorAndreas Schneider <asn@samba.org>
Tue, 16 Jul 2024 08:45:53 +0000 (10:45 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 18 Jul 2024 12:47:30 +0000 (12:47 +0000)
"Error: UNINIT (CWE-457):
samba-4.20.0rc2/examples/winexe/winexesvc.c:60: var_decl: Declaring variable ""ea"" without initializer.
samba-4.20.0rc2/examples/winexe/winexesvc.c:86: uninit_use_in_call: Using uninitialized value ""ea"". Field ""ea.Trustee.pMultipleTrustee"" is uninitialized when calling ""SetEntriesInAclA"".
   84|
   85|    /* Create a new ACL that contains the new ACEs */
   86|->  dwRes = SetEntriesInAcl(1, &ea, NULL, &pACL);
   87|    if (ERROR_SUCCESS != dwRes) {
   88|    dbg(""SetEntriesInAcl Error %lu\n"", GetLastError());"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
examples/winexe/winexesvc.c

index 980f4d1ab6dc681beb19f2a51789ad00a2bb66fe..a1937f9abd985a2111f2367a7ce9dc3f103cd8be 100644 (file)
@@ -57,7 +57,20 @@ static int CreatePipesSA()
        PSID pAdminSID = NULL;
        PACL pACL = NULL;
        PSECURITY_DESCRIPTOR pSD = NULL;
-       EXPLICIT_ACCESS ea;
+       /*
+        * Initialize an EXPLICIT_ACCESS structure for an ACE.
+        * The ACE will allow the Administrators group full access to the key.
+        */
+       EXPLICIT_ACCESS ea = {
+               .grfAccessPermissions = FILE_ALL_ACCESS,
+               .grfAccessMode = SET_ACCESS,
+               .grfInheritance = NO_INHERITANCE,
+               .Trustee = {
+                       .TrusteeForm = TRUSTEE_IS_SID,
+                       .TrusteeType = TRUSTEE_IS_GROUP,
+                       .ptstrName = (LPTSTR)pAdminSID,
+               },
+       };
        SID_IDENTIFIER_AUTHORITY SIDAuthNT = {SECURITY_NT_AUTHORITY};
 
        /* Create a SID for the BUILTIN\Administrators group. */
@@ -72,15 +85,6 @@ static int CreatePipesSA()
                dbg("AllocateAndInitializeSid Error %lu\n", GetLastError());
                return 0;
        }
-       /* Initialize an EXPLICIT_ACCESS structure for an ACE.
-          The ACE will allow the Administrators group full access to the key.
-       */
-       ea.grfAccessPermissions = FILE_ALL_ACCESS;
-       ea.grfAccessMode = SET_ACCESS;
-       ea.grfInheritance = NO_INHERITANCE;
-       ea.Trustee.TrusteeForm = TRUSTEE_IS_SID;
-       ea.Trustee.TrusteeType = TRUSTEE_IS_GROUP;
-       ea.Trustee.ptstrName = (LPTSTR) pAdminSID;
 
        /* Create a new ACL that contains the new ACEs */
        dwRes = SetEntriesInAcl(1, &ea, NULL, &pACL);