[parted-devel] [PATCH 22/24] ui: Fix gcc 10 warning about snprintf truncating an int

Brian C. Lane bcl at redhat.com
Sat Nov 14 00:12:05 GMT 2020


Double the storage to 20 bytes.
---
 parted/ui.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/parted/ui.c b/parted/ui.c
index 8e1f2fe..73fdcf5 100644
--- a/parted/ui.c
+++ b/parted/ui.c
@@ -909,11 +909,11 @@ command_line_get_word (const char* prompt, const char* def,
 int
 command_line_get_integer (const char* prompt, int* value)
 {
-        char     def_str [10];
+        char     def_str [20];
         char*    input;
         long     ret;
 
-        snprintf (def_str, 10, "%d", *value);
+        snprintf (def_str, 20, "%d", *value);
         input = command_line_get_word (prompt, *value ? def_str : NULL,
                                        NULL, 1);
         if (!input)
-- 
2.26.2




More information about the parted-devel mailing list