From: Stephen Hemminger Date: Wed, 14 Jan 2015 02:06:16 +0000 (-0800) Subject: neighbor: check return values X-Git-Tag: v3.19.0~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=542b0cc759c6d3456d16c05c886b367e1b2f1e73;p=thirdparty%2Fiproute2.git neighbor: check return values Need to check for invalid address and buffer overrun in ip neigh command with invalid paramters. --- diff --git a/ip/ipneigh.c b/ip/ipneigh.c index 6be79e1ae..eeec7bdd7 100644 --- a/ip/ipneigh.c +++ b/ip/ipneigh.c @@ -157,14 +157,19 @@ static int ipneigh_modify(int cmd, int flags, int argc, char **argv) exit(-1); } req.ndm.ndm_family = dst.family; - addattr_l(&req.n, sizeof(req), NDA_DST, &dst.data, dst.bytelen); + if (addattr_l(&req.n, sizeof(req), NDA_DST, &dst.data, dst.bytelen) < 0) + return -1; if (lla && strcmp(lla, "null")) { char llabuf[20]; int l; l = ll_addr_a2n(llabuf, sizeof(llabuf), lla); - addattr_l(&req.n, sizeof(req), NDA_LLADDR, llabuf, l); + if (l < 0) + return -1; + + if (addattr_l(&req.n, sizeof(req), NDA_LLADDR, llabuf, l) < 0) + return -1; } ll_init_map(&rth);