Skip to content

Commit 101dd04

Browse files
committed
fix lldpad netlink heap access overrun
Signed-off-by: Chunjie Zhu <chunjie.zhu@cloud.com>
1 parent d2ea5f1 commit 101dd04

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lldp_util.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,7 @@ int is_macvtap(const char *ifname)
674674
{
675675
int ret, s, realsize;
676676
struct nlmsghdr *nlh;
677+
struct nlmsghdr *temp;
677678
struct ifinfomsg *ifinfo;
678679
struct nlattr *tb[IFLA_MAX+1],
679680
*tb2[IFLA_INFO_MAX+1];
@@ -708,16 +709,15 @@ int is_macvtap(const char *ifname)
708709
realsize = recv(s, NULL, 0, MSG_DONTWAIT | MSG_PEEK | MSG_TRUNC);
709710
} while ((realsize < 0) && errno == EINTR);
710711

711-
if (realsize <= 0) {
712+
if (realsize < 0) {
712713
goto out_free;
713714
}
714715

715-
free(nlh);
716-
nlh = calloc(1, realsize);
717-
718-
if (!nlh) {
719-
goto out;
716+
temp = realloc(nlh, realsize);
717+
if (!temp) {
718+
goto out_free;
720719
}
720+
nlh = temp;
721721

722722
do {
723723
ret = recv(s, (void *) nlh, realsize, MSG_DONTWAIT);

0 commit comments

Comments
 (0)