[USETUP] Use RtlStringCbPrintfA instead of sprintf
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Sun, 28 Apr 2019 19:03:35 +0000 (21:03 +0200)
committerHervé Poussineau <hpoussin@reactos.org>
Mon, 27 May 2019 11:22:40 +0000 (13:22 +0200)
Fixes GCC 8 warning:
base/setup/usetup/usetup.c:3407:78: error: '%S' directive writing up to 521 bytes into a region of size 200 [-Werror=format-overflow=]
                 "Setup is currently unable to check a partition formatted in %S.\n"
                                                                              ^~
base/setup/usetup/usetup.c:3406:9: note: 'sprintf' output between 128 and 649 bytes into a destination of size 260
         sprintf(Buffer,
         ^~~~~~~~~~~~~~~
                 "Setup is currently unable to check a partition formatted in %S.\n"
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                 "\n"
                 ~~~~
                 "  \x07  Press ENTER to continue Setup.\n"
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                 "  \x07  Press F3 to quit Setup.",
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                 PartEntry->FileSystem);
                 ~~~~~~~~~~~~~~~~~~~~~~

base/setup/usetup/usetup.c

index 82716f6..239fd34 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <usetup.h>
 #include <math.h>
+#include <ntstrsafe.h>
 
 #include "bootsup.h"
 #include "chkdsk.h"
@@ -3403,12 +3404,13 @@ CheckFileSystemPage(PINPUT_RECORD Ir)
          */
         PartEntry->NeedsCheck = FALSE;
 
-        sprintf(Buffer,
-                "Setup is currently unable to check a partition formatted in %S.\n"
-                "\n"
-                "  \x07  Press ENTER to continue Setup.\n"
-                "  \x07  Press F3 to quit Setup.",
-                PartEntry->FileSystem);
+        RtlStringCbPrintfA(Buffer,
+                           sizeof(Buffer),
+                           "Setup is currently unable to check a partition formatted in %S.\n"
+                           "\n"
+                           "  \x07  Press ENTER to continue Setup.\n"
+                           "  \x07  Press F3 to quit Setup.",
+                           PartEntry->FileSystem);
 
         PopupError(Buffer,
                    MUIGetString(STRING_QUITCONTINUE),