diff options
author | Mattias Andrée <maandree@member.fsf.org> | 2015-12-29 01:06:41 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@member.fsf.org> | 2015-12-29 01:06:41 +0100 |
commit | 35b8a29eb2be26dda8dd2fec32cb1ae73bafeb1e (patch) | |
tree | 0b0d4c5d3e6ecb2867d38b9854717828913b2bce | |
parent | fix errors (diff) | |
download | sat-35b8a29eb2be26dda8dd2fec32cb1ae73bafeb1e.tar.gz sat-35b8a29eb2be26dda8dd2fec32cb1ae73bafeb1e.tar.bz2 sat-35b8a29eb2be26dda8dd2fec32cb1ae73bafeb1e.tar.xz |
more character that are not sh safe
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
-rw-r--r-- | src/satd-list.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/satd-list.c b/src/satd-list.c index e6bcfd7..a9fce0f 100644 --- a/src/satd-list.c +++ b/src/satd-list.c @@ -20,7 +20,6 @@ * DEALINGS IN THE SOFTWARE. */ #include "daemon.h" -#include <stdio.h> @@ -39,18 +38,20 @@ static char * quote(const char *str) { - size_t in = 0; /* < ' ' */ - size_t sn = 0; /* = ' ', '"' or '$' */ - size_t bn = 0; /* = '\\' */ - size_t qn = 0; /* = '\'' */ - size_t rn = 0; /* other */ +#define UNSAFE(c) strchr(" \"$()[]{};|&^#!?*~`<>", c) + + size_t in = 0; /* < ' ' */ + size_t sn = 0; /* in UNSAFE */ + size_t bn = 0; /* = '\\' */ + size_t qn = 0; /* = '\'' */ + size_t rn = 0; /* other */ size_t n, i = 0; const unsigned char *s; char *rc; for (s = (const unsigned char *)str; *s; s++) { if (*s < ' ') in++; - else if (*s == ' ') sn++; + else if (UNSAFE(*s)) sn++; else if (*s == '"') sn++; else if (*s == '$') sn++; else if (*s == '\\') bn++; @@ -86,9 +87,6 @@ quote(const char *str) rc[i++] = "0123456789ABCDEF"[(*s >> 4) & 15]; rc[i++] = "0123456789ABCDEF"[(*s >> 0) & 15]; } - else if (*s == ' ') rc[i++] = (char)*s; - else if (*s == '"') rc[i++] = (char)*s; - else if (*s == '$') rc[i++] = (char)*s; else if (*s == '\\') rc[i++] = '\\', rc[i++] = (char)*s; else if (*s == '\'') rc[i++] = '\\', rc[i++] = (char)*s; else rc[i++] = (char)*s; |