mirror of
https://github.com/containers/fuse-overlayfs.git
synced 2025-08-04 10:25:58 -04:00
containerfs: check for invalid mappings
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
parent
f131a755fa
commit
df766f09cb
17
main.c
17
main.c
@ -152,7 +152,7 @@ lo_data (fuse_req_t req)
|
|||||||
static struct lo_mapping *
|
static struct lo_mapping *
|
||||||
read_mappings (const char *str)
|
read_mappings (const char *str)
|
||||||
{
|
{
|
||||||
char *buf = NULL, *saveptr = NULL, *it;
|
char *buf = NULL, *saveptr = NULL, *it, *endptr;
|
||||||
struct lo_mapping *tmp, *ret = NULL;
|
struct lo_mapping *tmp, *ret = NULL;
|
||||||
unsigned int a, b, c;
|
unsigned int a, b, c;
|
||||||
int state = 0;
|
int state = 0;
|
||||||
@ -165,17 +165,23 @@ read_mappings (const char *str)
|
|||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
a = strtol (it, NULL, 10);
|
a = strtol (it, &endptr, 10);
|
||||||
|
if (*endptr != 0)
|
||||||
|
error (EXIT_FAILURE, 0, "invalid mapping specified: %s", str);
|
||||||
state++;
|
state++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
b = strtol (it, NULL, 10);
|
b = strtol (it, &endptr, 10);
|
||||||
|
if (*endptr != 0)
|
||||||
|
error (EXIT_FAILURE, 0, "invalid mapping specified: %s", str);
|
||||||
state++;
|
state++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
c = strtol (it, NULL, 10);
|
c = strtol (it, &endptr, 10);
|
||||||
|
if (*endptr != 0)
|
||||||
|
error (EXIT_FAILURE, 0, "invalid mapping specified: %s", str);
|
||||||
state = 0;
|
state = 0;
|
||||||
|
|
||||||
tmp = malloc (sizeof (*tmp));
|
tmp = malloc (sizeof (*tmp));
|
||||||
@ -190,6 +196,9 @@ read_mappings (const char *str)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (state != 0)
|
||||||
|
error (EXIT_FAILURE, 0, "invalid mapping specified: %s", str);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user