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

commit f3a9b524f102eb4c9f8759d0c51990e354f488a2
Author:     Timo Kreuzer <[email protected]>
AuthorDate: Sat Apr 27 16:05:40 2019 +0200
Commit:     Timo Kreuzer <[email protected]>
CommitDate: Sat Jul 20 13:56:18 2019 +0200

    [ADVAPI32] Fix copying the TokenSource string
    
    TOKEN_SOURCE::SourceString is an 8 char non-null-terminated string. Copy it 
as such.
    
    Fixes GCC 8 warning:
    dll/win32/advapi32/misc/logon.c:638:5: error: 'strncpy' output truncated 
before terminating nul copying 8 bytes from a string of the same length 
[-Werror=stringop-truncation]
         strncpy(TokenSource.SourceName, "Advapi  ", 
sizeof(TokenSource.SourceName));
         
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
 dll/win32/advapi32/misc/logon.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/dll/win32/advapi32/misc/logon.c b/dll/win32/advapi32/misc/logon.c
index 742c0931785..1262f1b652d 100644
--- a/dll/win32/advapi32/misc/logon.c
+++ b/dll/win32/advapi32/misc/logon.c
@@ -11,6 +11,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(advapi);
 
 /* GLOBALS *****************************************************************/
 
+static const CHAR AdvapiTokenSourceName[] = "Advapi  ";
+C_ASSERT(sizeof(AdvapiTokenSourceName) == RTL_FIELD_SIZE(TOKEN_SOURCE, 
SourceName) + 1);
+
 HANDLE LsaHandle = NULL;
 ULONG AuthenticationPackage = 0;
 
@@ -635,7 +638,9 @@ LogonUserExW(
                                         SE_GROUP_ENABLED_BY_DEFAULT;
 
     /* Set the token source */
-    strncpy(TokenSource.SourceName, "Advapi  ", 
sizeof(TokenSource.SourceName));
+    RtlCopyMemory(TokenSource.SourceName,
+                  AdvapiTokenSourceName,
+                  sizeof(TokenSource.SourceName));
     AllocateLocallyUniqueId(&TokenSource.SourceIdentifier);
 
     Status = LsaLogonUser(LsaHandle,

Reply via email to