btrfs-progs: do not modify the string in parse_range
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@suse.com>
This commit is contained in:
parent
9288d0bc23
commit
2b7f0192e8
|
@ -101,6 +101,7 @@ static int parse_u64(const char *str, u64 *result)
|
||||||
static int parse_range(const char *range, u64 *start, u64 *end)
|
static int parse_range(const char *range, u64 *start, u64 *end)
|
||||||
{
|
{
|
||||||
char *dots;
|
char *dots;
|
||||||
|
char *endptr;
|
||||||
const char *rest;
|
const char *rest;
|
||||||
int skipped = 0;
|
int skipped = 0;
|
||||||
|
|
||||||
|
@ -109,20 +110,21 @@ static int parse_range(const char *range, u64 *start, u64 *end)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
rest = dots + 2;
|
rest = dots + 2;
|
||||||
*dots = 0;
|
|
||||||
|
|
||||||
if (!*rest) {
|
if (!*rest) {
|
||||||
*end = (u64)-1;
|
*end = (u64)-1;
|
||||||
skipped++;
|
skipped++;
|
||||||
} else {
|
} else {
|
||||||
if (parse_u64(rest, end))
|
*end = strtoull(rest, &endptr, 10);
|
||||||
|
if (*endptr)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (dots == range) {
|
if (dots == range) {
|
||||||
*start = 0;
|
*start = 0;
|
||||||
skipped++;
|
skipped++;
|
||||||
} else {
|
} else {
|
||||||
if (parse_u64(range, start))
|
*end = strtoull(range, &endptr, 10);
|
||||||
|
if (*endptr != 0 && *endptr != '.')
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue