diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2016-06-10 14:30:56 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2016-06-15 12:12:38 +0200 |
commit | 8f4de3888ce74607d4754fe5a1a8f470af409c09 (patch) | |
tree | 7ea9c708919c990a496aaf2478acc346e9338360 /src/expr.c | |
parent | 844541f4c43c2469b9955b78480cbe36fde653d0 (diff) |
src: return value on setters that internally allocate memory
So the client can bail out of memory allocation errors. Or in case of
daemon, make sure things are left in consistent state before bailing
out.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/expr.c')
-rw-r--r-- | src/expr.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -60,18 +60,18 @@ bool nftnl_expr_is_set(const struct nftnl_expr *expr, uint16_t type) } EXPORT_SYMBOL_ALIAS(nftnl_expr_is_set, nft_rule_expr_is_set); -void -nftnl_expr_set(struct nftnl_expr *expr, uint16_t type, - const void *data, uint32_t data_len) +int nftnl_expr_set(struct nftnl_expr *expr, uint16_t type, + const void *data, uint32_t data_len) { switch(type) { case NFTNL_EXPR_NAME: /* cannot be modified */ - return; + return 0; default: if (expr->ops->set(expr, type, data, data_len) < 0) - return; + return -1; } expr->flags |= (1 << type); + return 0; } EXPORT_SYMBOL_ALIAS(nftnl_expr_set, nft_rule_expr_set); @@ -103,10 +103,9 @@ nftnl_expr_set_u64(struct nftnl_expr *expr, uint16_t type, uint64_t data) } EXPORT_SYMBOL_ALIAS(nftnl_expr_set_u64, nft_rule_expr_set_u64); -void -nftnl_expr_set_str(struct nftnl_expr *expr, uint16_t type, const char *str) +int nftnl_expr_set_str(struct nftnl_expr *expr, uint16_t type, const char *str) { - nftnl_expr_set(expr, type, str, strlen(str)+1); + return nftnl_expr_set(expr, type, str, strlen(str) + 1); } EXPORT_SYMBOL_ALIAS(nftnl_expr_set_str, nft_rule_expr_set_str); |