summaryrefslogtreecommitdiffstats
path: root/arch/sandbox
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2020-09-14 12:05:49 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2020-09-14 15:50:26 +0200
commitddcd3d43c1132e5754fa91398dd2138a35660c43 (patch)
tree3a1b3600a08fa53b047b749afd733c1a93cdbab1 /arch/sandbox
parent5fb2a0e8342424665a01d510ee64d742f586f877 (diff)
downloadbarebox-ddcd3d43c1132e5754fa91398dd2138a35660c43.tar.gz
barebox-ddcd3d43c1132e5754fa91398dd2138a35660c43.tar.xz
sandbox: support escaping commas in --image filenames
Some tools like afl-fuzz generate file names containing commas. Allow escaping the commas in the file names, so they can be passed to barebox. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/sandbox')
-rw-r--r--arch/sandbox/os/common.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index 9f26f8fa6e..437fe3ecdf 100644
--- a/arch/sandbox/os/common.c
+++ b/arch/sandbox/os/common.c
@@ -212,6 +212,8 @@ int linux_execve(const char * filename, char *const argv[], char *const envp[])
extern void start_barebox(void);
extern void mem_malloc_init(void *start, void *end);
+extern char * strsep_unescaped(char **s, const char *ct);
+
static int add_image(char *str, char *devname_template, int *devname_number)
{
struct hf_info *hf = malloc(sizeof(struct hf_info));
@@ -225,15 +227,15 @@ static int add_image(char *str, char *devname_template, int *devname_number)
if (!hf)
return -1;
- filename = strtok(str, ",");
- while ((opt = strtok(NULL, ","))) {
+ filename = strsep_unescaped(&str, ",");
+ while ((opt = strsep_unescaped(&str, ","))) {
if (!strcmp(opt, "ro"))
readonly = 1;
}
/* parses: "devname=filename" */
- devname = strtok(filename, "=");
- filename = strtok(NULL, "=");
+ devname = strsep_unescaped(&filename, "=");
+ filename = strsep_unescaped(&filename, "=");
if (!filename) {
filename = devname;
snprintf(tmp, sizeof(tmp),