← back to index · 2026-12-02

Fixing Nmap's getCompletionFraction Off-by-One Probe Budget

nmap c++ networking

Repo: kwaadrat/nmap · Branch: fix/scan-progress-allowedtryno · Commit: dd4b8ae

The Bug

In scan_engine.cc, UltraScanInfo::getCompletionFraction estimates remaining scan work per incomplete host using host->allowedTryno(NULL, NULL). However, allowedTryno returns the maximum retry number (0-indexed from the retransmission perspective), so the initial probe itself was omitted from maxtries.

The Fix

-    int maxtries = host->allowedTryno(NULL, NULL);
+    int maxtries = host->allowedTryno(NULL, NULL) + 1;

Adding + 1 aligns the completion denominator with the actual probe budget sent per host, which is especially noticeable when running aggressive scans with low retry limits (--max-retries 0 or 1).