From nobody Thu Jan 16 16:54:54 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 4YYprG6Z0Nz5kfvM; Thu, 16 Jan 2025 16:54:54 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YYprG5rKdz3Ktb; Thu, 16 Jan 2025 16:54:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737046494; 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=qCoXtvho4vgiYLduib5Zb3aL2rzK/Ah4L4EQY4IjlmU=; b=IVTEYjfquz6ZHGm40QPF2YskkJ7wBYjDQS83fipWeoDKZOUFHS5XDTFfnUYF0bbMADSoH/ jtWnNmCOexNjH1G16D0KhFDSt9TrIXD0T5HzQcegrPJk5YW2LdGEH8UqLrm2PhS6SE7xAd 553T1sWUlVhzAaQGXX4t1wtQIX59x6yopuE69J7DJ6h+PoAL+4dtaIvG93WUiogUzDob0q zRa3Z4Icdye0fvwk2N0lpy0OA/YHCTwTNSYYAh6UZwdZs+wY1Te5WD5wRaqgK2hICa0uqb 94csEPgTzt88SSMjdIr67EDwVOhiglZth3FF4ovDmcNE7RgWW8f/hUeDtqa72Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737046494; 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=qCoXtvho4vgiYLduib5Zb3aL2rzK/Ah4L4EQY4IjlmU=; b=npx9PBAQAbE46Ik7ALAR1raWkKx2SKiGIFwIE0XG7U4MfSwAZ8MuOI4g4+Q1FXQ5fr1vT/ shnadyuJ5XSMXwv/pGG+QP6ZtQbknIPeSCY9nB1r9g8TJMO2CbvFGNVT6MJsjp113Ciu0V v7ztpvfo1y21X+DhfaZfU01PeRyWCkdFeoUxT+3sD9mxFgQWQAYkoexopHUYw0W/DPBwCL +8Wf/EsDoA2Qd1QQwUjUEQPcDrtT5JLcy96s9UqjFxzkKPx2u/uRdi8wjM2njl9igcRZDa AsPGFI7r4HvJtMGmOyFg6+4jsV0YYIV2FeH98MCgogkwzqxEhJ0SuaiPqKNurQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1737046494; a=rsa-sha256; cv=none; b=kq+SJiH8VtgdcssvqpirBIGu8k5QOljCmm3K9LZpXjU/2xgb5c0NjuDVzO5FaROHh9SSG4 hxw0dIgSt/2DLsQK7HmVpkOoEJhGdA7XvLK2GMHcgTGwPjrF4P+yTCZHkk55VLtxN14GRH Mf59Xv4O4VASrXjJvo6km5bRkGR7l5+aEiEqP2rxqNIn+5RqGpUhj8lNYnGsGcAid6ZMDr Xns8cvxSX9MnDqmWtLzWEEWXWOCSPWquI8PjwBq8FIgG2stcVH3EqO1+YUZweC/BNxUjft h2tHyz+2lURU7ba4qf79u+gawapVevYcxpyLzYoUfStC2RFYNSKCMYb2nEZ69w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4YYprG5L7szhGk; Thu, 16 Jan 2025 16:54:54 +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 50GGsslc057842; Thu, 16 Jan 2025 16:54:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50GGssak057839; Thu, 16 Jan 2025 16:54:54 GMT (envelope-from git) Date: Thu, 16 Jan 2025 16:54:54 GMT Message-Id: <202501161654.50GGssak057839@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: c1557708f1fa - main - pkg: Fix Coverity warnings 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c1557708f1fae1bb9c8e23e3bbb2aa2b055e1211 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=c1557708f1fae1bb9c8e23e3bbb2aa2b055e1211 commit c1557708f1fae1bb9c8e23e3bbb2aa2b055e1211 Author: Mark Johnston AuthorDate: 2025-01-16 15:09:58 +0000 Commit: Mark Johnston CommitDate: 2025-01-16 16:45:15 +0000 pkg: Fix Coverity warnings - Fix allocation size in config_get_repositories(). - Fix a memory leak in read_conf_file(). - Avoid a null pointer dereference in an error path in verify_pubsignature(). Fixes: e3b4a51580fc ("pkg(7): expand VERSION_MAJOR, VERSION_MINOR, RELEASE and OSNAME") Fixes: dc4581589a32 ("pkg: clean support for repositories") --- usr.sbin/pkg/config.c | 17 ++++++++++------- usr.sbin/pkg/pkg.c | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/usr.sbin/pkg/config.c b/usr.sbin/pkg/config.c index 26d7dd66b2a4..6649e75b7f6b 100644 --- a/usr.sbin/pkg/config.c +++ b/usr.sbin/pkg/config.c @@ -476,9 +476,9 @@ read_conf_file(const char *confpath, const char *requested_repo, { struct ucl_parser *p; ucl_object_t *obj = NULL; - const char *abi = pkg_get_myabi(); - char *major, *minor; + char *abi = pkg_get_myabi(), *major, *minor; struct utsname uts; + int ret; if (uname(&uts)) err(EXIT_FAILURE, "uname"); @@ -502,9 +502,9 @@ read_conf_file(const char *confpath, const char *requested_repo, if (errno != ENOENT) errx(EXIT_FAILURE, "Unable to parse configuration " "file %s: %s", confpath, ucl_parser_get_error(p)); - ucl_parser_free(p); /* no configuration present */ - return (1); + ret = 1; + goto out; } obj = ucl_parser_get_object(p); @@ -517,13 +517,16 @@ read_conf_file(const char *confpath, const char *requested_repo, else if (conftype == CONFFILE_REPO) parse_repo_file(obj, requested_repo); } - ucl_object_unref(obj); + + ret = 0; +out: ucl_parser_free(p); + free(abi); free(major); free(minor); - return (0); + return (ret); } static void @@ -674,7 +677,7 @@ config_get_repositories(void) { if (STAILQ_EMPTY(&repositories)) { /* Fall back to PACKAGESITE - deprecated - */ - struct repository *r = calloc(1, sizeof(r)); + struct repository *r = calloc(1, sizeof(*r)); if (r == NULL) err(EXIT_FAILURE, "calloc"); r->name = strdup("fallback"); diff --git a/usr.sbin/pkg/pkg.c b/usr.sbin/pkg/pkg.c index 21ee1cd4bd30..92fdbf0ebff8 100644 --- a/usr.sbin/pkg/pkg.c +++ b/usr.sbin/pkg/pkg.c @@ -664,7 +664,7 @@ verify_pubsignature(int fd_pkg, int fd_sig, struct repository *r) pubkey = r->pubkey; } else { if (config_string(PUBKEY, &pubkey) != 0) { - warnx("No CONFIG_PUBKEY defined for %s", r->name); + warnx("No CONFIG_PUBKEY defined"); goto cleanup; } }