Browse Source

libobs: Avoid strncpy warning

jpark37 4 years ago
parent
commit
54047ef9ca
1 changed files with 4 additions and 1 deletions
  1. 4 1
      libobs/util/platform-nix.c

+ 4 - 1
libobs/util/platform-nix.c

@@ -460,7 +460,10 @@ struct os_dirent *os_readdir(os_dir_t *dir)
 	if (!dir->cur_dirent)
 	if (!dir->cur_dirent)
 		return NULL;
 		return NULL;
 
 
-	strncpy(dir->out.d_name, dir->cur_dirent->d_name, 255);
+	const size_t length = strlen(dir->cur_dirent->d_name);
+	if (sizeof(dir->out.d_name) <= length)
+		return NULL;
+	memcpy(dir->out.d_name, dir->cur_dirent->d_name, length + 1);
 
 
 	dstr_copy(&file_path, dir->path);
 	dstr_copy(&file_path, dir->path);
 	dstr_cat(&file_path, "/");
 	dstr_cat(&file_path, "/");