netfilter: nfnetlink_hook: fix check for snprintf() overflow
The kernel version of snprintf() can't return negatives. The
"ret > (int)sizeof(sym)" check is off by one because and it should be
>=. Finally, we need to set a negative error code.
Fixes: e2cf17d377
("netfilter: add new hook nfnl subsystem")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
parent
3078d964c0
commit
24610ed80d
|
@ -126,8 +126,10 @@ static int nfnl_hook_dump_one(struct sk_buff *nlskb,
|
|||
|
||||
#ifdef CONFIG_KALLSYMS
|
||||
ret = snprintf(sym, sizeof(sym), "%ps", ops->hook);
|
||||
if (ret < 0 || ret > (int)sizeof(sym))
|
||||
if (ret >= sizeof(sym)) {
|
||||
ret = -EINVAL;
|
||||
goto nla_put_failure;
|
||||
}
|
||||
|
||||
module_name = strstr(sym, " [");
|
||||
if (module_name) {
|
||||
|
|
Loading…
Reference in New Issue