[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] [PATCH] check sector number in dmsetup message



atoll doesn't check for errors, so invalid sector numbers were silently
accepted in the "dmsetup message" command.

Signed-off-by: Mikulas Patocka <mpatocka redhat com>

---
 tools/dmsetup.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Index: LVM2.2.02.96/tools/dmsetup.c
===================================================================
--- LVM2.2.02.96.orig/tools/dmsetup.c	2012-08-23 03:27:51.000000000 +0200
+++ LVM2.2.02.96/tools/dmsetup.c	2012-08-23 03:29:48.000000000 +0200
@@ -769,6 +769,8 @@ static int _message(CMD_ARGS)
 	size_t sz = 1;
 	struct dm_task *dmt;
 	char *str;
+	uint64_t sector;
+	char *endptr;
 
 	if (!(dmt = dm_task_create(DM_DEVICE_TARGET_MSG)))
 		return 0;
@@ -783,7 +785,12 @@ static int _message(CMD_ARGS)
 		argv++;
 	}
 
-	if (!dm_task_set_sector(dmt, (uint64_t) atoll(argv[1])))
+	sector = strtoull(argv[1], &endptr, 10);
+	if (*endptr || endptr == argv[1]) {
+		err("invalid sector");
+		goto out;
+	}
+	if (!dm_task_set_sector(dmt, sector))
 		goto out;
 
 	argc -= 2;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]