From cfe671fa741c9669cadc5dfbf9ae63eb440601cf Mon Sep 17 00:00:00 2001 From: Arturo Borrero Date: Wed, 26 Feb 2014 19:13:26 +0100 Subject: src: check if netlink parsing fails We have to check if mnl_attr_parse() returns an error, which means that it failed to validate and retrieve the attributes. Signed-off-by: Arturo Borrero Gonzalez Signed-off-by: Pablo Neira Ayuso --- examples/nft-compat-get.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'examples/nft-compat-get.c') diff --git a/examples/nft-compat-get.c b/examples/nft-compat-get.c index 3294028..8f00cbf 100644 --- a/examples/nft-compat-get.c +++ b/examples/nft-compat-get.c @@ -51,7 +51,8 @@ static int cb(const struct nlmsghdr *nlh, void *data) struct nlattr *tb[NFTA_COMPAT_MAX+1] = {}; struct nfgenmsg *nfg = mnl_nlmsg_get_payload(nlh); - mnl_attr_parse(nlh, sizeof(*nfg), data_attr_cb, tb); + if (mnl_attr_parse(nlh, sizeof(*nfg), data_attr_cb, tb) < 0) + return MNL_CB_ERROR; if (tb[NFTA_COMPAT_NAME]) printf("name=%s ", mnl_attr_get_str(tb[NFTA_COMPAT_NAME])); -- cgit v1.2.3