From nobody Thu Mar 06 15:39:59 2025 X-Original-To: dev-commits-src-all@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 4Z7tsC6HPvz5pnPj; Thu, 06 Mar 2025 15:39:59 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Z7tsC4jKsz3l4t; Thu, 06 Mar 2025 15:39:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1741275599; 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=ue2ViTI8+p76bOq5iJgyOGThFXtAndYGMa8TMYCnajk=; b=etvFZBB3cImdgDMhAYEHOD9xCl/fZO+LGykahRGh3hUxcdgRrVNqQxbzJ2bXKJFswZbxty pu2xI//R1ZoZUIaGTik1RkiSu3GdZOC5q3w4QcT3bZcI7bw2N5Dww0HHBUdapLJenIQr1F YCQpNVYtoW2iY2/wof1I386SBkWdpElgAW9YpYvla3ZKfLA4vffbSn57YhjcSIb1kzmB/e JhLBCICzmoRbFzdNvz3pLMT8B0WxMn9EECP3TGy2/rdb3JoHSnDRsh1bB6VvR1Z8tBVcdw tCyinyU7UH/mCEfqiGwbH0WrxA7ag2gxnRMGZ+6bQEnPAidLY4wb0mA5fqn1+Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1741275599; a=rsa-sha256; cv=none; b=Ns8eebLbjjyjuabIwR3ya8N5qbCbefccrrG8xThl8PwRODph3IMjh8GgUpfTrThnQeHQbu PA2DtAuxeAw8EkFGGSDnPGleAf9XddaoAVwQepKgy7wmyPsuOu8sz1uC1F9GSDWyuQcfDG Ay6VWrvAnvcPRrWd2HfIyOOfhxMnn0SKuxxTS1BzrXsUaakQvCegG31pqkrwnH6g32AkZ5 RZxfYV2xD0ZbgVp4f2Fo7hvdHMWodmNDFJVoCJEvn8A/XMCmMGWvCjuxR4Hchm4gFn8yNo JwYnG1pceSNx9pUUEDx+AI/n/KrdxmHl01dtf+zjl2ujM6nmXfmIXYpeXkaAVg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1741275599; 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=ue2ViTI8+p76bOq5iJgyOGThFXtAndYGMa8TMYCnajk=; b=HzYk1lx4YGIeuDrgeaaIIT0jQ8aPbuEXVt/O2IWaHzVnVNBLrpVdGJMFwsFTGWj3x+NWA2 W6y+OGxyKKA6f9V2V3Q2ltySsuOWNROibuKIMC4iWyvRUyHbOJAeb5jdic4yfgsrnVBcFb 8jXpbkX8dx8XR3MHUe5yLiA8IoObJVkbfttWxfuoGiThIK2X9QUUyGgtjbFxwQDP8mStxL 0LVPBhOnRaDiS/VP1l148kUXRlQ+IWu2TT+S0p5ZfB1gvgCqjnKKevpySOyB1wZXzHHTmc PYpZovdBO1T7lxmFaPW84+8SSZvz7lLoDFqp24b+r98xsJkuTQ8btonMTYTEXQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Z7tsC4CVRzww5; Thu, 06 Mar 2025 15:39:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 526Fdx8J028781; Thu, 6 Mar 2025 15:39:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 526FdxOt028778; Thu, 6 Mar 2025 15:39:59 GMT (envelope-from git) Date: Thu, 6 Mar 2025 15:39:59 GMT Message-Id: <202503061539.526FdxOt028778@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Baptiste Daroussin Subject: git: c7c3f8dbcfae - stable/14 - pkg: make sure the repositories have at least an url List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bapt X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: c7c3f8dbcfaeac5b4f881d329cf6cec92a8521df Auto-Submitted: auto-generated The branch stable/14 has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=c7c3f8dbcfaeac5b4f881d329cf6cec92a8521df commit c7c3f8dbcfaeac5b4f881d329cf6cec92a8521df Author: Baptiste Daroussin AuthorDate: 2025-01-15 08:06:55 +0000 Commit: Baptiste Daroussin CommitDate: 2025-03-06 15:37:51 +0000 pkg: make sure the repositories have at least an url While here, factorize code to free the repository structure (cherry picked from commit eccf736c3ce6e9566fa9923080b4c24ee7f9ae2a) --- usr.sbin/pkg/config.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/usr.sbin/pkg/config.c b/usr.sbin/pkg/config.c index ce73a08d93f3..521360c642d6 100644 --- a/usr.sbin/pkg/config.c +++ b/usr.sbin/pkg/config.c @@ -1,9 +1,8 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2014 Baptiste Daroussin + * Copyright (c) 2014-2025 Baptiste Daroussin * Copyright (c) 2013 Bryan Drewery - * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -333,6 +332,16 @@ parse_mirror_type(struct repository *r, const char *mt) r->mirror_type = MIRROR_NONE; } +static void +repo_free(struct repository *r) +{ + free(r->name); + free(r->url); + free(r->fingerprints); + free(r->pubkey); + free(r); +} + static bool parse_signature_type(struct repository *repo, const char *st) { @@ -345,11 +354,7 @@ parse_signature_type(struct repository *repo, const char *st) else { warnx("Signature type %s is not supported for bootstraping," " ignoring repository %s", st, repo->name); - free(repo->url); - free(repo->name); - free(repo->fingerprints); - free(repo->pubkey); - free(repo); + repo_free(repo); return false; } return (true); @@ -393,13 +398,16 @@ parse_repo(const ucl_object_t *o) } else if (strcasecmp(key, "enabled") == 0) { if ((cur->type != UCL_BOOLEAN) || !ucl_object_toboolean(cur)) { - free(repo->url); - free(repo->name); - free(repo); + repo_free(repo); return; } } } + /* At least we need an url */ + if (repo->url == NULL) { + repo_free(repo); + return; + } STAILQ_INSERT_TAIL(&repositories, repo, next); return; }