Before touching src/http.c, we verified the exact source tree shipped in a public Yocto Scarthgap firmware image for a 32-bit ARM Cortex-A5 gateway. The recipe built GNU Wget 1.21.4 on top of two earlier CVE patches. Comparing the firmware’s wget binary against the vendor SDK confirmed a byte-for-byte match, and applying the recipe’s existing patches reproduced the exact http.c packaged in the SDK’s debug sources.
When long is 32 bits and file offsets are 64
CVE-2026-58470 sits in parse_content_range(), the parser Wget runs when resuming an interrupted download (wget -c). Upstream commit 43d3ba9336bc replaced an unchecked decimal loop with strtol(). On a 64-bit x86_64 build host, both long and Wget’s wgint file-offset type are 64 bits wide, so multi-gigabyte offsets pass without trouble. Cross-compiled for 32-bit ARM and run under QEMU user mode with the gateway’s SDK libraries, Wget’s range unit tests failed on any offset above 2 GiB:
/* First upstream commit (43d3ba9336bc): 32-bit long on ARM32 sets ERANGE above 2 GiB */
num = strtol(hdr, &end, 10);
/* Follow-up commit (01ff771caac1): 64-bit conversion matching wgint */
num = strtoll(hdr, &end, 10);
Even on 32-bit ARM, Wget builds with large-file support (64-bit off_t), so saving a 3 GiB archive works until a dropped link forces parse_content_range() to read the byte position back through a 32-bit long. Backporting Tim Rühsen’s follow-up commit 01ff771caac1 restored the full 64-bit range on ARM.
The off-by-one ceiling that wrote zero bytes
Reading the caller in gethttp() raised a second question. After parse_content_range() validates the start byte, end byte, and total length, gethttp() computes last_byte_pos + 1 to derive the transfer length. When the server sends * for an unknown total size, WGINT_MAX (9223372036854775807) passes strtoll() without setting ERANGE, leaving no room for the caller’s + 1:
/* HTTP/1.1 206 Partial Content
* Content-Range: bytes 0-9223372036854775807/*
*/
if (*last_byte_ptr < *first_byte_ptr || *last_byte_ptr == WGINT_MAX)
return false;
We tested that header against GNU Wget’s upstream development branch with a local server sending the six bytes hello\n. Without the WGINT_MAX guard, last_byte_pos + 1 overflowed signed 64-bit arithmetic into a negative download length: Wget created an empty file, wrote none of the six bytes, and exited with status 0.
Rejecting last_byte_ptr == WGINT_MAX, adding 19 boundary parser cases, and asserting saved file contents in an HTTP 206 test closed that gap. On the Scarthgap 1.21.4 series (walked through in our case study), all 15 unit-test groups passed on the host under UBSan and on 32-bit ARM under QEMU, alongside all four localhost download and resume tests. Jabar Asadi submitted the parser check and six-byte regression test upstream in GNU Wget merge request !89.