瀏覽代碼

core: use memcpy and set end of string

Daniel-Constantin Mierla 3 年之前
父節點
當前提交
5cd4e817a2
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      src/core/socket_info.c

+ 2 - 1
src/core/socket_info.c

@@ -1551,7 +1551,8 @@ static int build_iface_list(void)
 			}
 
 			if(strlen(ifaces[index].name)==0 && strlen(name)>0) {
-				strncpy(ifaces[index].name, name, MAX_IF_LEN-1);
+				memcpy(ifaces[index].name, name, MAX_IF_LEN-1);
+				ifaces[index].name[MAX_IF_LEN-1] = '\0';
 			}
 
 			ifaces[index].index = index;