Skip to content

Commit 7922216

Browse files
committed
rtsold: Fix a buffer leak if we fail to read the default router sysctl
MFC after: 1 week Reported by: Kevin Day <[email protected]>
1 parent 0795e9b commit 7922216

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

usr.sbin/rtsold/cap_sendmsg.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,10 @@ probe_defrouters(uint32_t ifindex, uint32_t linkid)
151151
buf = malloc(len);
152152
if (buf == NULL)
153153
return (-1);
154-
if (sysctl(mib, nitems(mib), buf, &len, NULL, 0) < 0)
154+
if (sysctl(mib, nitems(mib), buf, &len, NULL, 0) < 0) {
155+
free(buf);
155156
return (-1);
157+
}
156158
ep = (struct in6_defrouter *)(void *)(buf + len);
157159
for (p = (struct in6_defrouter *)(void *)buf; p < ep; p++) {
158160
if (ifindex != p->if_index)

0 commit comments

Comments
 (0)