From a90d5bf1284980151dec17acd763fb2d317cce4f Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 15 Feb 2026 13:49:24 -0600 Subject: avoid NRE if provided file list is null, check each filename within for validity --- src/slskd/Transfers/Downloads/DownloadService.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/slskd/Transfers/Downloads/DownloadService.cs b/src/slskd/Transfers/Downloads/DownloadService.cs index beeab755..17ebf089 100644 --- a/src/slskd/Transfers/Downloads/DownloadService.cs +++ b/src/slskd/Transfers/Downloads/DownloadService.cs @@ -246,13 +246,18 @@ namespace slskd.Transfers.Downloads throw new ArgumentException("Username is required", nameof(username)); } - var fileList = files.ToList(); + var fileList = files?.ToList() ?? []; if (fileList.Count == 0) { throw new ArgumentException("At least one file is required", nameof(files)); } + if (fileList.Any(f => string.IsNullOrWhiteSpace(f.Filename))) + { + throw new ArgumentException("At least one filename is null, empty, or consists of only whitespace", nameof(files)); + } + if (fileList.Count != fileList.Distinct().Count()) { throw new ArgumentException("Two or more files in request are duplicated", nameof(files)); -- cgit v1.2.3