curl/tests
Keng-Yu Lin 703a999602
tests: fix type promotion on 32-bit arches in http test code
As reported in the bug:

> On a 32-bit architecture (i386):
> 1. `chunks * chunk_size` evaluates to `unsigned int` (32-bit
>    unsigned).
> 2. Due to Usual Arithmetic Conversions in C, the signed `-1` (int)
>    operand of the ternary operator is promoted to `unsigned int`,
>    yielding `4294967295` (0xFFFFFFFF).
> 3. The ternary operator returns `4294967295` as an `unsigned int`.
> 4. This unsigned value is then assigned to `r->clength` (apr_off_t,
>    64-bit signed). Since the source is unsigned, it is zero-extended,
>    resulting in `r->clength` becoming `+4294967295`.
> 5. The subsequently executed check `if(r->clength >= 0)` evaluates to
>    true.
> 6. Inside the block, `apr_ltoa(r->pool, (long)r->clength)` casts it to
>    a 32-bit signed `long` (on 32-bit platforms), which truncates it
>    back to `-1`, formatting it as "-1" and sending the
>    "Content-Length: -1" header.
>
> On a 64-bit architecture (amd64), `size_t` is 64-bit, and `-1` (32-bit
> int) is promoted to `unsigned long` (64-bit), yielding
> `18446744073709551615`. When assigned to `r->clength` (64-bit signed),
> it wraps back to `-1`, which correctly skips the Content-Length
> generation.
>
> This type promotion mismatch can be safely fixed by avoiding the
> signed/unsigned mixture in the ternary operator.

Origin: debian, https://bugs.debian.org/1140793
Bug-Debian: https://bugs.debian.org/1140793

These are standard Debian patches' trailers, I can get rid of then if you prefer.

I've tested the fix using [debusine on i386 runner](https://debusine.debian.net/debian/developers/artifact/4083252/raw/log):

> 782s tests/http/test_05_errors.py::TestErrors::test_05_04_unclean_tls_shutdown[http/1.0] PASSED [ 17%]
> 782s tests/http/test_05_errors.py::TestErrors::test_05_04_unclean_tls_shutdown[http/1.1] PASSED [ 18%]
> 782s tests/http/test_05_errors.py::TestErrors::test_05_04_unclean_tls_shutdown[h2] PASSED [ 18%]

Versus the [i386 run in Debian's infrastructure](https://debusine.debian.net/debian/developers/artifact/4084220/raw/log):

> 2690s tests/http/test_05_errors.py::TestErrors::test_05_04_unclean_tls_shutdown[http/1.0] FAILED [ 17%]
> 2690s tests/http/test_05_errors.py::TestErrors::test_05_04_unclean_tls_shutdown[http/1.1] PASSED [ 18%]
> 2690s tests/http/test_05_errors.py::TestErrors::test_05_04_unclean_tls_shutdown[h2] PASSED [ 18%]

Closes #22210
2026-07-20 19:13:53 +02:00
..
certs TLS: drop support for TLS-SRP 2026-07-04 12:20:20 +02:00
cmake scripts: use end-of-options marker in cd, mkdir, mv, sha256sum commands 2026-06-25 11:32:36 +02:00
data cfilters: fix event-based connection shutdown 2026-07-17 04:00:56 -04:00
http tests: fix type promotion on 32-bit arches in http test code 2026-07-20 19:13:53 +02:00
libtest cfilters: fix event-based connection shutdown 2026-07-17 04:00:56 -04:00
server hostip: only cache negative resolves for authoritative answers 2026-07-13 11:27:16 +02:00
tunit
unit cfilters: fix event-based connection shutdown 2026-07-17 04:00:56 -04:00
.gitignore
allversions.pm tidy-up: syntax and code nits 2026-06-26 15:45:24 +02:00
appveyor.pm
azure.pm
CMakeLists.txt cmake: fix not to build tunits when BUILD_CURL_EXE=OFF 2026-06-26 21:12:35 +02:00
config.in
configurehelp.pm.in
devtest.pl
dictserver.py
directories.pm
ech_combos.py
ech_tests.sh scripts: use end-of-options marker in cd, mkdir, mv, sha256sum commands 2026-06-25 11:32:36 +02:00
ftpserver.pl runtests: flush cached test parts when (re)loading a file 2026-07-15 16:36:36 -07:00
getpart.pm runtests: flush cached test parts when (re)loading a file 2026-07-15 16:36:36 -07:00
globalconfig.pm
http-server.pl
http2-server.pl
http3-server.pl
Makefile.am tidy-up: syntax and code nits 2026-06-26 15:45:24 +02:00
memanalyze.pl
memanalyzer.pm
negtelnetserver.py
nghttpx.conf
pathhelp.pm
processhelp.pm
requirements.txt
rtspserver.pl
runner.pm runtests: flush cached test parts when (re)loading a file 2026-07-15 16:36:36 -07:00
runtests.pl ssls: fix potential memory leak on import 2026-07-15 22:18:04 +02:00
secureserver.pl tidy-up: typos, comment nits 2026-07-11 13:55:45 +02:00
serverhelp.pm TLS: drop support for TLS-SRP 2026-07-04 12:20:20 +02:00
servers.pm TLS: drop support for TLS-SRP 2026-07-04 12:20:20 +02:00
smbserver.py
sshhelp.pm
sshserver.pl
test745.pl
test971.pl
test1119.pl
test1135.pl
test1139.pl tidy-up: docs, comments, typos, whitespace 2026-06-26 11:36:09 +02:00
test1140.pl tidy-up: docs, comments, typos, whitespace 2026-06-26 11:36:09 +02:00
test1165.pl TLS: drop support for TLS-SRP 2026-07-04 12:20:20 +02:00
test1167.pl
test1173.pl
test1175.pl
test1177.pl TLS: drop support for TLS-SRP 2026-07-04 12:20:20 +02:00
test1222.pl
test1275.pl
test1276.pl
test1477.pl
test1486.pl
test1488.pl
test1544.pl
test1707.pl tidy-up: syntax and code nits 2026-06-26 15:45:24 +02:00
testcurl.pl
testutil.pm tidy-up: syntax and code nits 2026-06-26 15:45:24 +02:00
tftpserver.pl
util.py
valgrind.pm
valgrind.supp