[parted-devel] [PATCH 5/5] parted: Fix partition number allocation in do_print

Brian C. Lane bcl at redhat.com
Mon Sep 14 19:10:04 BST 2026


GPT can have up to 8192 partitions, but we only allocate 4 bytes (two of
which are for a space and a \0). Increase this to 6 so that more than 99
partitions doesn't overflow the temporary variable.
---
 parted/parted.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/parted/parted.c b/parted/parted.c
index 7f3b81d0..f86619f7 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -1414,7 +1414,7 @@ do_print (PedDevice** dev, PedDisk** diskp)
                         part->type & PED_PARTITION_METADATA)
                             continue;
 
-                    tmp = ped_malloc (4);
+                    tmp = ped_malloc (6);
 
                     if (part->num >= 0)
                             sprintf (tmp, "%2d ", part->num);
-- 
2.55.0




More information about the parted-devel mailing list