修改原版代码中strlcpy最大8个字节的限制, "enp175s0f0"这种网卡名被截断的BUG.

This commit is contained in:
lijia
2019-07-12 14:50:30 +08:00
parent f36a4fca25
commit 408d23b286
3 changed files with 47 additions and 43 deletions

View File

@@ -73,7 +73,8 @@ get_interface(interface_list_t *list, const char *alias)
} while (ptr != NULL);
} else {
name = (char *)safe_malloc(strlen(alias) + 1);
strlcpy(name, alias, sizeof(name));
memset(name, 0, strlen(alias) + 1);
strncpy(name, alias, strlen(alias) + 1);
return(name);
}