We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d2ea5f1 commit 101dd04Copy full SHA for 101dd04
1 file changed
lldp_util.c
@@ -674,6 +674,7 @@ int is_macvtap(const char *ifname)
674
{
675
int ret, s, realsize;
676
struct nlmsghdr *nlh;
677
+ struct nlmsghdr *temp;
678
struct ifinfomsg *ifinfo;
679
struct nlattr *tb[IFLA_MAX+1],
680
*tb2[IFLA_INFO_MAX+1];
@@ -708,16 +709,15 @@ int is_macvtap(const char *ifname)
708
709
realsize = recv(s, NULL, 0, MSG_DONTWAIT | MSG_PEEK | MSG_TRUNC);
710
} while ((realsize < 0) && errno == EINTR);
711
- if (realsize <= 0) {
712
+ if (realsize < 0) {
713
goto out_free;
714
}
715
- free(nlh);
716
- nlh = calloc(1, realsize);
717
-
718
- if (!nlh) {
719
- goto out;
+ temp = realloc(nlh, realsize);
+ if (!temp) {
+ goto out_free;
720
+ nlh = temp;
721
722
do {
723
ret = recv(s, (void *) nlh, realsize, MSG_DONTWAIT);
0 commit comments