🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: muc.lists.freebsd.bugs
Article #668

[Bug 301055] libfetch: HTTP 206 reply to a request without Range is written as the whole file

#668
From: bugzilla-noreply
Date: Mon, 23 Nov 2026 18:49
62 lines
3985 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301055

            Bug ID: 301055
           Summary: libfetch: HTTP 206 reply to a request without Range is
                    written as the whole file
           Product: Base System
           Version: 15.1-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: laamalif@proton.me

If fetch doesn't send a Range header and the server answers 206 with a
Content-Range that doesn't start at 0, fetch writes the partial body as the
whole file and exits 0.

For example, with a server that replies

    HTTP/1.1 206 Partial Content
    Content-Range: bytes 3-9/10
    Content-Length: 7

`fetch -o out http://host/f` leaves a 7 byte file that starts at offset 3 of
the real file, and returns 0. I saw this on 15.1-RELEASE-p6 (arm64) with the
stock /usr/bin/fetch. The server log shows that the request had no Range
header.

http_request_body() has a "too far?" check for a reply that starts after the
requested offset, but it is skipped when the requested offset is 0. After the
first reply, URL->offset holds the reply's start (3), so fetch.c thinks it was
a resume that failed, resets the offset to 0 and sends the same GET again. The
second reply is the same 206, the check is skipped again, and the body is
written.

With no offset the reply may start at 0 and no later, so the check can always
run. The attached patch drops the "URL->offset > 0 &&". With it the same server
gives "Protocol error", exit 1, and one connection instead of two. `-r` is not
affected: resuming from a 3 byte file with a 206 starting at 3 still appends.

I don't have a real server that does this unasked, so I don't know how often it
matters. It looked wrong while reading the code.

-- 
You are receiving this mail because:
You are the assignee for the bug.

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Technical Details
Message-ID: <bug-301055-227@https.bugs.freebsd.org/bugzilla/>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!usenet.goja.nl.eu.org!2.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mail

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!usenet.goja.nl.eu.org!2.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mail
From: bugzilla-noreply@freebsd.org
Newsgroups: muc.lists.freebsd.bugs
Subject: [Bug 301055] libfetch: HTTP 206 reply to a request without Range is
 written as the whole file
Date: Mon, 23 Nov 2026 18:49:32 +0000
Organization: Newsgate at muc.de e.V.
Approved: news-admin@muc.de
Distribution: world
Message-ID: <bug-301055-227@https.bugs.freebsd.org/bugzilla/>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: news.muc.de; posting-host="news.muc.de:193.149.48.2";
	logging-data="95831"; mail-complaints-to="news-admin@muc.de"
X-Original-To: bugs@mlmmj.nyi.freebsd.org
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim;
	t=1795459772;
	h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
	 to:to:cc:mime-version:mime-version:content-type:content-type:
	 content-transfer-encoding:content-transfer-encoding;
	bh=4SRtyhrzKKmGSI/891EybeJ2lBfKRG29QZ0bzT4v4G8=;
	b=P5KgA60ghpVvdDIb3WpIg6eYmMR9gxTl0pHLD8Xigb1XfFJ6ADABM4Ney9lcQBKau14Fvz
	UwT4QmRUz9bdpEpCHu/HRss3bSlMyYQUabLHY+PRKgOHreYe+uhTAm1gbgaAprDZ6KyKDD
	84Vv6sHr5OZRYm4PeA0z/GtwvWtJXCwFbolctJ/eAYXN3zXaFX4zS06rcY0HW9RK4auLpJ
	3CWQzEis52ITL9eNbWjdXxbZONF1HjSUugF4zaVvO3zCpbG93CciCwkUwKNuzKXGDuOUls
	8UYaCIgiS8GoSO3QFDc05zxMb21yHoL0T4stefM77ZqnbvvjAObCyKRPRMnJ1A==
X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f
Auto-Submitted: auto-generated
Precedence: list
X-Newsgate-Id: f02c70b8849f+
X-No-Archive: Yes