[RSAENH] Use StringCbPrintfA instead of sprintf
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Sun, 28 Apr 2019 16:01:11 +0000 (18:01 +0200)
committerHervé Poussineau <hpoussin@reactos.org>
Mon, 27 May 2019 11:22:40 +0000 (13:22 +0200)
Fixes GCC 8 warning:
dll/win32/rsaenh/rsaenh.c:161:23: error: '%s' directive writing up to 259 bytes into a region of size 235 [-Werror=format-overflow=]
 #define RSAENH_REGKEY "Software\\Wine\\Crypto\\RSA\\%s"
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dll/win32/rsaenh/rsaenh.c:161:23: note: in definition of macro 'RSAENH_REGKEY'
 #define RSAENH_REGKEY "Software\\Wine\\Crypto\\RSA\\%s"
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dll/win32/rsaenh/rsaenh.c:1107:5: note: 'sprintf' output between 26 and 285 bytes into a destination of size 260
     sprintf(szRSABase, RSAENH_REGKEY, pKeyContainer->szName);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

dll/win32/rsaenh/rsaenh.c

index bb28c99..f23c8d8 100644 (file)
@@ -43,6 +43,7 @@
 #include <objbase.h>
 #include <rpcproxy.h>
 #include <aclapi.h>
+#include <strsafe.h>
 
 WINE_DEFAULT_DEBUG_CHANNEL(crypt);
 
@@ -1104,7 +1105,7 @@ static BOOL create_container_key(KEYCONTAINER *pKeyContainer, REGSAM sam, HKEY *
     CHAR szRSABase[MAX_PATH];
     HKEY hRootKey;
 
-    sprintf(szRSABase, RSAENH_REGKEY, pKeyContainer->szName);
+    StringCbPrintfA(szRSABase, sizeof(szRSABase), RSAENH_REGKEY, pKeyContainer->szName);
 
     if (pKeyContainer->dwFlags & CRYPT_MACHINE_KEYSET)
         hRootKey = HKEY_LOCAL_MACHINE;