diff options
author | Phillip Lougher <phillip@squashfs.org.uk> | 2017-07-18 04:45:58 +0100 |
---|---|---|
committer | Phillip Lougher <phillip@squashfs.org.uk> | 2017-07-31 19:20:59 +0100 |
commit | 00c9237041a068dd410e67b774fd25dcc6aee47e (patch) | |
tree | 113cb065e586f1fdfebad1d325384939b001b76f | |
parent | 83e05169a448dc9fe6f281248b141f708a5c00e0 (diff) | |
download | squashfs-tools-00c9237041a068dd410e67b774fd25dcc6aee47e.tar.gz |
pseudo: handle quoted filenames
Typically there are two methods of handling filenames with spaces.
Either backslash the space, or quote the filename.
Pesudo allowed backslashing but oddly didn't allow quoting.
Correct that deficiency now.
Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
-rw-r--r-- | squashfs-tools/pseudo.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/squashfs-tools/pseudo.c b/squashfs-tools/pseudo.c index 0f15ebe..95635cb 100644 --- a/squashfs-tools/pseudo.c +++ b/squashfs-tools/pseudo.c @@ -2,7 +2,7 @@ * Create a squashfs filesystem. This is a highly compressed read only * filesystem. * - * Copyright (c) 2009, 2010, 2012, 2014 + * Copyright (c) 2009, 2010, 2012, 2014, 2017 * Phillip Lougher <phillip@squashfs.org.uk> * * This program is free software; you can redistribute it and/or @@ -274,6 +274,7 @@ struct pseudo_dev *get_pseudo_file(int pseudo_id) int read_pseudo_def(char *def) { int n, bytes; + int quoted = 0; unsigned int major = 0, minor = 0, mode; char type, *ptr; char suid[100], sgid[100]; /* overflow safe */ @@ -284,13 +285,22 @@ int read_pseudo_def(char *def) /* * Scan for filename, don't use sscanf() and "%s" because - * that can't handle filenames with spaces + * that can't handle filenames with spaces. + * + * Filenames with spaces should either escape (backslash) the + * space or use double quotes. */ filename = malloc(strlen(def) + 1); if(filename == NULL) MEM_ERROR(); - for(name = filename; !isspace(*def) && *def != '\0';) { + for(name = filename; (quoted || !isspace(*def)) && *def != '\0';) { + if(*def == '"') { + quoted = !quoted; + def ++; + continue; + } + if(*def == '\\') { def ++; if (*def == '\0') |