aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2026-02-15 13:49:24 -0600
committerJP Dillingham <jp@dillingham.me>2026-02-15 13:49:24 -0600
commita90d5bf1284980151dec17acd763fb2d317cce4f (patch)
tree2ddd022adb8803891721f8ecbfe894e0b2ac5d85 /src
parent54203c1678cea4f68348d0ee8a813bb717d38677 (diff)
downloadslskd-a90d5bf1284980151dec17acd763fb2d317cce4f.tar.gz
avoid NRE if provided file list is null, check each filename within for validity
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Transfers/Downloads/DownloadService.cs7
1 files changed, 6 insertions, 1 deletions
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));