From 30952670c2333d793f4d0bf9025be9c787672a8c Mon Sep 17 00:00:00 2001 From: Michael Grafnetter Date: Tue, 24 Mar 2026 13:21:04 -0700 Subject: [PATCH] Fix arithmetic overflow in Test-PasswordQuality with empty dictionary file The ReportProgress method would divide by zero when fileLength was 0. Add an early return when fileLength <= 0 to prevent the division. Fixes #219 Co-Authored-By: Claude Opus 4.6 --- .../Commands/Misc/TestPasswordQualityCommand.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Src/DSInternals.PowerShell/Commands/Misc/TestPasswordQualityCommand.cs b/Src/DSInternals.PowerShell/Commands/Misc/TestPasswordQualityCommand.cs index d3d2a19..5d749c8 100644 --- a/Src/DSInternals.PowerShell/Commands/Misc/TestPasswordQualityCommand.cs +++ b/Src/DSInternals.PowerShell/Commands/Misc/TestPasswordQualityCommand.cs @@ -442,10 +442,13 @@ private void TestWeakNTHashesFromUnsortedFile() private void ReportProgress(long fileLength, long position, ProgressRecord progress) { - if (position >= fileLength) + if (fileLength <= 0 || position >= fileLength) { // Report operation completion progress.RecordType = ProgressRecordType.Completed; + progress.PercentComplete = 100; + this.WriteProgress(progress); + return; } // Calculate the current progress