Skip to content

Commit

Permalink
core: copy discovered interface name only when its len is > 0
Browse files Browse the repository at this point in the history
  • Loading branch information
miconda committed May 21, 2019
1 parent 64f744e commit 69b87dd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/core/socket_info.c
Expand Up @@ -1155,6 +1155,7 @@ static int build_iface_list(void)
entry->ifa_flags = ifi->ifa_flags;
is_link_local = 0;

name[0] = '\0';
for(;RTA_OK(rtap, rtl);rtap=RTA_NEXT(rtap,rtl)){
switch(rtap->rta_type){
case IFA_ADDRESS:
Expand Down Expand Up @@ -1194,8 +1195,9 @@ static int build_iface_list(void)
}
}

if(strlen(ifaces[index].name)==0)
if(strlen(ifaces[index].name)==0 && strlen(name)>0) {
strncpy(ifaces[index].name, name, MAX_IF_LEN-1);
}

ifaces[index].index = index;

Expand Down

0 comments on commit 69b87dd

Please sign in to comment.