lib: fix getsockopt_cmsg_data retrieval

The `type` parameter was not being compared with `cmsg_type`, so the
result of this function was always a pointer to the first header
matching the level.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
This commit is contained in:
Rafael Zalamena 2018-05-30 17:04:57 -03:00
parent aa0b1d3b60
commit dc094865db

View File

@ -75,7 +75,7 @@ static void *getsockopt_cmsg_data(struct msghdr *msgh, int level, int type)
for (cmsg = ZCMSG_FIRSTHDR(msgh); cmsg != NULL;
cmsg = CMSG_NXTHDR(msgh, cmsg))
if (cmsg->cmsg_level == level && cmsg->cmsg_type)
if (cmsg->cmsg_level == level && cmsg->cmsg_type == type)
return (ptr = CMSG_DATA(cmsg));
return NULL;