Date: Wed, 15 Jan 2025 08:21:29 GMT From: Baptiste Daroussin <bapt@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: eccf736c3ce6 - main - pkg: make sure the repositories have at least an url Message-ID: <202501150821.50F8LTBR096329@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=eccf736c3ce6e9566fa9923080b4c24ee7f9ae2a commit eccf736c3ce6e9566fa9923080b4c24ee7f9ae2a Author: Baptiste Daroussin <bapt@FreeBSD.org> AuthorDate: 2025-01-15 08:06:55 +0000 Commit: Baptiste Daroussin <bapt@FreeBSD.org> CommitDate: 2025-01-15 08:21:19 +0000 pkg: make sure the repositories have at least an url While here, factorize code to free the repository structure --- 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 fe1599f42c2c..3aaa7a7815e8 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 <bapt@FreeBSD.org> + * Copyright (c) 2014-2025 Baptiste Daroussin <bapt@FreeBSD.org> * Copyright (c) 2013 Bryan Drewery <bdrewery@FreeBSD.org> - * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -332,6 +331,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) { @@ -344,11 +353,7 @@ parse_signature_type(struct repository *repo, const char *st) else { warnx("Signature type %s is not supported for bootstrapping," " 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); @@ -392,13 +397,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; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202501150821.50F8LTBR096329>