Skip to content

Commit b0dbfcc

Browse files
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 <noreply@anthropic.com>
1 parent 2f14e8f commit b0dbfcc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Src/DSInternals.PowerShell/Commands/Misc/TestPasswordQualityCommand.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,10 +442,13 @@ private void TestWeakNTHashesFromUnsortedFile()
442442

443443
private void ReportProgress(long fileLength, long position, ProgressRecord progress)
444444
{
445-
if (position >= fileLength)
445+
if (fileLength <= 0 || position >= fileLength)
446446
{
447447
// Report operation completion
448448
progress.RecordType = ProgressRecordType.Completed;
449+
progress.PercentComplete = 100;
450+
this.WriteProgress(progress);
451+
return;
449452
}
450453

451454
// Calculate the current progress

0 commit comments

Comments
 (0)