diff --git a/libnetutils/ifc_utils.c b/libnetutils/ifc_utils.c index 4e7340125..8212eba29 100644 --- a/libnetutils/ifc_utils.c +++ b/libnetutils/ifc_utils.c @@ -267,19 +267,13 @@ int ifc_act_on_address(int action, const char *name, const char *address, struct { struct nlmsghdr n; struct ifaddrmsg r; - // Allow for IPv6 address, headers, IPv4 broadcast addr and padding. - char attrbuf[NLMSG_ALIGN(sizeof(struct nlmsghdr)) + - NLMSG_ALIGN(sizeof(struct rtattr)) + - NLMSG_ALIGN(INET6_ADDRLEN) + - NLMSG_ALIGN(sizeof(struct rtattr)) + - NLMSG_ALIGN(INET_ADDRLEN)]; + // Allow for IPv4 or IPv6 address, headers, IPv4 broadcast address and padding. + char attrbuf[NLMSG_ALIGN(sizeof(struct rtattr)) + NLMSG_ALIGN(INET6_ADDRLEN) + + NLMSG_ALIGN(sizeof(struct rtattr)) + NLMSG_ALIGN(INET_ADDRLEN)]; } req; struct rtattr *rta; struct nlmsghdr *nh; struct nlmsgerr *err; - char buf[NLMSG_ALIGN(sizeof(struct nlmsghdr)) + - NLMSG_ALIGN(sizeof(struct nlmsgerr)) + - NLMSG_ALIGN(sizeof(struct nlmsghdr))]; // Get interface ID. ifindex = if_nametoindex(name); @@ -348,6 +342,7 @@ int ifc_act_on_address(int action, const char *name, const char *address, return -saved_errno; } + char buf[NLMSG_ALIGN(sizeof(struct nlmsgerr)) + sizeof(req)]; len = recv(s, buf, sizeof(buf), 0); saved_errno = errno; close(s);