[PATCH] test correctly for snprintf failure

Karel Zak kzak at redhat.com
Thu Mar 5 17:34:47 UTC 2009


* libparted/arch/linux.c (_device_get_partition_range): Correct
test for failed snprintf.
---
 libparted/arch/linux.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 724df46..047ed50 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2279,7 +2279,7 @@ _device_get_partition_range(PedDevice* dev)

         r = snprintf(path, sizeof(path), "/sys/block/%s/range",
                         basename(dev->path));
-        if(r < 0 || r > sizeof(path))
+        if(r < 0 || r >= sizeof(path))
                 return MAX_NUM_PARTS;

         fp = fopen(path, "r");
--
1.6.2.rc1.285.gc5f54



More information about the parted-devel mailing list