#include #include "strbuf.h" #include "quote.h" #include "util.h" /* Help to copy the thing properly quoted for the shell safety. * any single quote is replaced with '\'', any exclamation point * is replaced with '\!', and the whole thing is enclosed in a * * E.g. * original sq_quote result * name ==> name ==> 'name' * a b ==> a b ==> 'a b' * a'b ==> a'\''b ==> 'a'\''b' * a!b ==> a'\!'b ==> 'a'\!'b' */ static inline int need_bs_quote(char c) { return (c == '\'' || c == '!'); } static int sq_quote_buf(struct strbuf *dst, const char *src) { char *to_free = NULL; int ret; if (dst->buf == src) to_free = strbuf_detach(dst, NULL); ret = strbuf_addch(dst, '\''); while (!ret && *src) { size_t len = strcspn(src, "'!"); ret = strbuf_add(dst, src, len); src += len; while (!ret && need_bs_quote(*src)) ret = strbuf_addf(dst, "'\\%c\'", *src++); } if (!ret) ret = strbuf_addch(dst, '\''); free(to_free); return ret; } int sq_quote_argv(struct strbuf *dst, const char** argv, size_t maxlen) { int i, ret; /* Copy into destination buffer. */ ret = strbuf_grow(dst, 255); for (i = 0; !ret && argv[i]; ++i) { ret = strbuf_addch(dst, ' '); if (ret) break; ret = sq_quote_buf(dst, argv[i]); if (maxlen && dst->len > maxlen) return -ENOSPC; } return ret; } it' value='switch'/> net-next plumbingsTobias Klauser
summaryrefslogtreecommitdiff
path: root/include/crypto
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2017-01-18 21:31:31 +0100
committerJohan Hovold <johan@kernel.org>2017-01-19 09:08:37 +0100
commit24d615a694d649aa2e167c3f97f62bdad07e3f84 (patch)
tree2fe33c115bdec6bf4b01e27afd90bb16fa668e22 /include/crypto
parent49def1853334396f948dcb4cedb9347abb318df5 (diff)
USB: serial: qcserial: add Dell DW5570 QDL
The Dell DW5570 is a re-branded Sierra Wireless MC8805 which will by default boot with vid 0x413c and pid 0x81a3. When triggered QDL download mode, the device switches to pid 0x81a6 and provides the standard TTY used for firmware upgrade. Cc: <stable@vger.kernel.org> Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Johan Hovold <johan@kernel.org>
Diffstat (limited to 'include/crypto')