diff options
author | Arturo Borrero <arturo.borrero.glez@gmail.com> | 2014-01-18 17:01:44 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2014-01-18 21:50:22 +0100 |
commit | 871c7fd0204325b947a5fde3ab8617ef89b9168f (patch) | |
tree | 22988ceef9730a8c41265e619335a7228457ec2c /src/utils.c | |
parent | cd9a80990abb035fba5810bbeb0ecdff46425d2f (diff) |
utils: fix nft_str2verdict return value
Some verdicts have a negative value.
The caller of nft_str2verdict() checking if return was < 0 clash with
enum nft_verdict.
While at it, add error reporting of invalid verdicts.
Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/utils.c')
-rw-r--r-- | src/utils.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/utils.c b/src/utils.c index 2415917..dd7fd1d 100644 --- a/src/utils.c +++ b/src/utils.c @@ -154,18 +154,24 @@ const char *nft_verdict2str(uint32_t verdict) } } -int nft_str2verdict(const char *verdict) +int nft_str2verdict(const char *verdict, int *verdict_num) { - if (strcmp(verdict, "accept") == 0) - return NF_ACCEPT; - else if (strcmp(verdict, "drop") == 0) - return NF_DROP; - else if (strcmp(verdict, "return") == 0) - return NFT_RETURN; - else if (strcmp(verdict, "jump") == 0) - return NFT_JUMP; - else if (strcmp(verdict, "goto") == 0) - return NFT_GOTO; + if (strcmp(verdict, "accept") == 0) { + *verdict_num = NF_ACCEPT; + return 0; + } else if (strcmp(verdict, "drop") == 0) { + *verdict_num = NF_DROP; + return 0; + } else if (strcmp(verdict, "return") == 0) { + *verdict_num = NFT_RETURN; + return 0; + } else if (strcmp(verdict, "jump") == 0) { + *verdict_num = NFT_JUMP; + return 0; + } else if (strcmp(verdict, "goto") == 0) { + *verdict_num = NFT_GOTO; + return 0; + } return -1; } |