From f3a9b524f102eb4c9f8759d0c51990e354f488a2 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sat, 27 Apr 2019 16:05:40 +0200 Subject: [PATCH] [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, -- 2.17.1