Compare commits

...

1 Commits

Author SHA1 Message Date
Xavier Roche
be9d914625 Stop -K from silently resetting the -c socket count
The option parser's `case 'K':` had no `break`, so a bare -K (no trailing
digit) fell through into `case 'c':`, hit its no-digit branch, and forced
the socket count back to the default of 4. `-c8 -K` ended up with 4
connections, not 8; the -K rewrite mode quietly overrode an earlier -c.
Only a trailing bare -K triggered it (`-K -c8` and `-Kc8` were fine),
which is why it went unnoticed.

Add the missing break. The regression test drives the observable that
maxsoc has: a socket count above 8 trips the "limited to 8" security
warning in hts-log.txt, so `-c16` warns and `-c16 -K` warns only if the
16 survives. It fails on the pre-fix build and passes after.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
2026-07-21 19:51:38 +02:00
2 changed files with 19 additions and 0 deletions

View File

@@ -1055,6 +1055,7 @@ static int hts_main_internal(int argc, char **argv, httrackp * opt) {
while(isdigit((unsigned char) *(com + 1)))
com++;
}
break;
case 'c':
if (isdigit((unsigned char) *(com + 1))) {
sscanf(com + 1, "%d", &opt->maxsoc);

View File

@@ -155,4 +155,22 @@ accepted "$tmp/pre-bti" "#615: -%i before the URL broke the crawl"
run_only "$tmp/pre-proto" "-@i2" "file://$tmp/index.html"
accepted "$tmp/pre-proto" "#615: -@i2 before the URL broke the crawl"
# -K must not reset the -c socket count (its case fell through into 'c'). maxsoc
# is only observable via the ">8, limited to 8" warning: -c16 trips it, and would
# stop tripping it if a trailing -K reset the count back to the default 4.
warned() {
grep -q 'simultaneous connections limited to' "$1/hts-log.txt" ||
! echo "FAIL: $2" || exit 1
}
not_warned() {
! grep -q 'simultaneous connections limited to' "$1/hts-log.txt" ||
! echo "FAIL: $2" || exit 1
}
run "$tmp/soc-c16" -c16
warned "$tmp/soc-c16" "-c16 did not trip the socket-count warning (probe blind)"
run "$tmp/soc-c16k" -c16 -K
warned "$tmp/soc-c16k" "-K reset the -c socket count (fell through into 'c')"
run "$tmp/soc-c8k" -c8 -K
not_warned "$tmp/soc-c8k" "-c8 -K spuriously warned"
exit 0