add_image modifies the argument passed to it, we want to reexec with
the original argv however, thus make a copy of the argument.

---
 arch/sandbox/os/common.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index 778ac3d6e60f..d0addef5af49 100644
--- a/arch/sandbox/os/common.c
+++ b/arch/sandbox/os/common.c
@@ -247,10 +247,10 @@ 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)
+static int add_image(const char *_str, char *devname_template, int 
*devname_number)
 {
        struct hf_info *hf = malloc(sizeof(struct hf_info));
-       char *filename, *devname;
+       char *str, *filename, *devname;
        char tmp[16];
        int readonly = 0, cdev = 0, blkdev = 0;
        struct stat s;
@@ -260,6 +260,8 @@ static int add_image(char *str, char *devname_template, int 
*devname_number)
        if (!hf)
                return -1;
 
+       str = strdup(_str);
+
        filename = strsep_unescaped(&str, ",");
        while ((opt = strsep_unescaped(&str, ","))) {
                if (!strcmp(opt, "ro"))
-- 
2.28.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to