#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; } ub'>net-next plumbingsTobias Klauser
summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2017-01-23 18:21:56 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2017-02-02 14:31:53 +0100
commitcb9c68363efb6d1f950ec55fb06e031ee70db5fc (patch)
tree081b7de4d5d3bb069beeaa17328f068686aae810 /include
parent97a6ad13decc16c5adbf181283932daba7e17faf (diff)
skbuff: add and use skb_nfct helper
Followup patch renames skb->nfct and changes its type so add a helper to avoid intrusive rename change later. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/skbuff.h13
-rw-r--r--include/net/netfilter/nf_conntrack_core.h2
2 files changed, 11 insertions, 4 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h