Module: wine Branch: oldstable Commit: 4c6c5137da029272f8025a57462874229498d552 URL: https://gitlab.winehq.org/wine/wine/-/commit/4c6c5137da029272f8025a574628742...
Author: Zebediah Figura zfigura@codeweavers.com Date: Thu Sep 15 23:21:48 2022 -0500
ntdll: Calculate the necessary length after calling snprintf() in SystemWineVersionInformation.
This works around a spurious gcc warning:
../wine/dlls/ntdll/unix/system.c: In function ‘NtQuerySystemInformation’: ../wine/dlls/ntdll/unix/system.c:3176:36: error: ‘%s’ directive output between 0 and 2147483644 bytes may cause result to exceed ‘INT_MAX’ [-Werror=format-truncation=] 3176 | snprintf( info, size, "%s%c%s%c%s%c%s", version, 0, wine_build, 0, buf.sysname, 0, buf.release ); | ^~ ~~~~~~~~~~ ../wine/dlls/ntdll/unix/system.c:3176:9: note: ‘snprintf’ output between 8 and 2147483780 bytes into a destination of size 4294967295 3176 | snprintf( info, size, "%s%c%s%c%s%c%s", version, 0, wine_build, 0, buf.sysname, 0, buf.release ); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(cherry picked from commit f66b49a4968a383bccab03dc200d5448a3ab15f3) Signed-off-by: Michael Stefaniuc mstefani@winehq.org
---
dlls/ntdll/unix/system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/ntdll/unix/system.c b/dlls/ntdll/unix/system.c index a06739388b8..5a94892b2ee 100644 --- a/dlls/ntdll/unix/system.c +++ b/dlls/ntdll/unix/system.c @@ -3200,8 +3200,8 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class, struct utsname buf;
uname( &buf ); - len = strlen(version) + strlen(wine_build) + strlen(buf.sysname) + strlen(buf.release) + 4; snprintf( info, size, "%s%c%s%c%s%c%s", version, 0, wine_build, 0, buf.sysname, 0, buf.release ); + len = strlen(version) + strlen(wine_build) + strlen(buf.sysname) + strlen(buf.release) + 4; if (size < len) ret = STATUS_INFO_LENGTH_MISMATCH; break; }