From nobody Wed Sep 30 16:55:48 2026 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4hw1QF2mxdz6tpvp for ; Wed, 30 Sep 2026 16:55:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hw1QF0gKSz4kCG for ; Wed, 30 Sep 2026 16:55:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1790787349; 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=j65rWXH0c9uFYyTbdqPy0ThwWQ4VOxZec8UGTBpf9/4=; b=A6GUj3hLJU9O6s4I3YdS36vILtJPfTyKkqgFmCW+BCbnnULo0trHEeCl/gyu5ivehaVmqg 35c/gmOx9IPmzFXt/gMDEeCoxELUuGGdH5S4q5bkn2BYaKarIE4prAdMx9P8ns6OHxEpzb xN+8zpLO7QkXreVbS9RHUNh6tK18akncnGTDxscSSIBwgIfDfjChHLKQiZUqwCXp63INim eD5/6ftNEJmqlZs8nln+bAIPWnf7e2QvR8hacb6Vyk1Bzzs2TADmJN3ubpza0kNcZio6T4 eI2cP3Gd7B85wrADYmSRBcpxq81Vn+EDtw7qI4vcY2+zH3oXctkMn+wji5gzGA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1790787349; b=tL9ADI/iWnCt9Sp3NUsfoORkfwBGsxa7x7kk8rE1DFe93mj0q/hhn3SDnb9i7EhxJntzvZ VWmR/Rke4h7NiKSHwHUVaA706I14kexNvLVHjykf7mBG8OzJmnM9cF9rqRL0xm+vFJuxYg aAC0nfffT0RezeGe9vCui7+faRMN9B8xbelsFsXfbcGW23ICQp/bTRmobh+6Kl/ulWfQeA Lceysdf15bf5w/9eSdXXIKt38gZhfK0AuUMgIw+fzDGawYgYjj9XzhwtinBS188Jpxkk9l Wl7vHePYtqDUvakifGFkg20h9W6XNjzhiuB18K94BpIZ1cIBTT4LI42x1dhKpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1790787349; 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=j65rWXH0c9uFYyTbdqPy0ThwWQ4VOxZec8UGTBpf9/4=; b=WeJz+svKeGea2JbhAGPSnwpGH/3cmzt+rHD16AUTTn3D1rhVVO2eRiYwq82QqTrl/B4gSf eQbmOi8MkoVllxv38pA8kYJEm66Jd8SdFsrYj1TvacHQVmEbcq9nl1Sp3Wr6F72pau0VX+ P3m+zibxF6/afu2n0OzHpakol6/GQt6KnCL2cUNbOvxT7ogUYs+N9VxrIgnWeWdKF7ls7l vUdN5dqW26mmdJHuhoN/75kowHzIXc8Riq8sEwrQ2OWvHa7y+fAJR9aDj5SuCYzXnkJ8zr WZmbGiHcqnilB6mUlKbzLtSmXjpOy0mtPR+iF5i5CkVjWhDUJSmbTZ9RxweKQw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hw1QD5ydbztbl for ; Wed, 30 Sep 2026 16:55:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3a1e4 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 30 Sep 2026 16:55:48 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: cd2fca49d31d - main - libfetch: Correctly free redirect target List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cd2fca49d31d06957027dd32538511ebe2938c1f Auto-Submitted: auto-generated Date: Wed, 30 Sep 2026 16:55:48 +0000 Message-Id: <6abd3f14.3a1e4.d03034c@gitrepo.freebsd.org> The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=cd2fca49d31d06957027dd32538511ebe2938c1f commit cd2fca49d31d06957027dd32538511ebe2938c1f Author: Dag-Erling Smørgrav AuthorDate: 2026-09-30 16:55:13 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-09-30 16:55:13 +0000 libfetch: Correctly free redirect target When processing a redirect, if we get multiple Location headers, we free the previous one using free(new) instead of fetchFreeURL(new), which leaks new->doc. While here, rename new to loc since new is a reserved word in C++. MFC after: 1 week Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D60015 --- lib/libfetch/http.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/libfetch/http.c b/lib/libfetch/http.c index cefa8adbb8bd..c5415b875155 100644 --- a/lib/libfetch/http.c +++ b/lib/libfetch/http.c @@ -1565,7 +1565,7 @@ http_request_body(struct url *URL, const char *op, struct url_stat *us, char timebuf[80]; char hbuf[MAXHOSTNAMELEN + 7], *host; conn_t *conn; - struct url *url, *new; + struct url *url, *loc; int chunked, direct, ims, noredirect, verbose; int e, i, n, val; off_t offset, clength, length, size; @@ -1602,7 +1602,7 @@ http_request_body(struct url *URL, const char *op, struct url_stat *us, e = HTTP_PROTOCOL_ERROR; do { - new = NULL; + loc = NULL; chunked = 0; offset = 0; clength = -1; @@ -1871,32 +1871,32 @@ http_request_body(struct url *URL, const char *op, struct url_stat *us, n = 1; break; } - if (new) - free(new); + if (loc != NULL) + fetchFreeURL(loc); if (verbose) fetch_info("%d redirect to %s", conn->err, p); if (*p == '/') /* absolute path */ - new = fetchMakeURL(url->scheme, url->host, + loc = fetchMakeURL(url->scheme, url->host, url->port, p, url->user, url->pwd); else - new = fetchParseURL(p); - if (new == NULL) { + loc = fetchParseURL(p); + if (loc == NULL) { /* XXX should set an error code */ DEBUGF("failed to parse new URL\n"); goto ouch; } /* Only copy credentials if the host matches */ - if (strcmp(new->host, url->host) == 0 && - !*new->user && !*new->pwd) { - strcpy(new->user, url->user); - strcpy(new->pwd, url->pwd); + if (strcmp(loc->host, url->host) == 0 && + !*loc->user && !*loc->pwd) { + strcpy(loc->user, url->user); + strcpy(loc->pwd, url->pwd); } - new->offset = url->offset; - new->length = url->length; - new->ims_time = url->ims_time; + loc->offset = url->offset; + loc->length = url->length; + loc->ims_time = url->ims_time; break; case hdr_transfer_encoding: /* XXX weak test*/ @@ -1965,13 +1965,13 @@ http_request_body(struct url *URL, const char *op, struct url_stat *us, clean_http_auth_challenges(&server_challenges); fetch_close(conn); conn = NULL; - if (!new) { + if (loc == NULL) { DEBUGF("redirect with no new location\n"); break; } if (url != URL) fetchFreeURL(url); - url = new; + url = loc; } while (++i < n); /* we failed, or ran out of retries */