[PATCH 2/8] btrfs-progs: do not modify the string in parse_range

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

 



It's passed as const but we modify it through 'dots'. This would break
parsing the string multiple times.

Signed-off-by: David Sterba <dsterba@xxxxxxxx>
---
 cmds-balance.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/cmds-balance.c b/cmds-balance.c
index 798b533aa7d6..0a1bf0cd0699 100644
--- a/cmds-balance.c
+++ b/cmds-balance.c
@@ -101,6 +101,7 @@ static int parse_u64(const char *str, u64 *result)
 static int parse_range(const char *range, u64 *start, u64 *end)
 {
 	char *dots;
+	char *endptr;
 	const char *rest;
 	int skipped = 0;
 
@@ -109,20 +110,21 @@ static int parse_range(const char *range, u64 *start, u64 *end)
 		return 1;
 
 	rest = dots + 2;
-	*dots = 0;
 
 	if (!*rest) {
 		*end = (u64)-1;
 		skipped++;
 	} else {
-		if (parse_u64(rest, end))
+		*end = strtoull(rest, &endptr, 10);
+		if (*endptr)
 			return 1;
 	}
 	if (dots == range) {
 		*start = 0;
 		skipped++;
 	} else {
-		if (parse_u64(range, start))
+		*end = strtoull(range, &endptr, 10);
+		if (*endptr != 0 && *endptr != '.')
 			return 1;
 	}
 
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux