From owner-svn-src-stable-12@freebsd.org Wed May 22 23:23:18 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D49E31590FA8; Wed, 22 May 2019 23:23:17 +0000 (UTC) (envelope-from sjg@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7850D70527; Wed, 22 May 2019 23:23:17 +0000 (UTC) (envelope-from sjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5238C247A7; Wed, 22 May 2019 23:23:17 +0000 (UTC) (envelope-from sjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4MNNHS6062176; Wed, 22 May 2019 23:23:17 GMT (envelope-from sjg@FreeBSD.org) Received: (from sjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4MNNH5v062175; Wed, 22 May 2019 23:23:17 GMT (envelope-from sjg@FreeBSD.org) Message-Id: <201905222323.x4MNNH5v062175@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sjg set sender to sjg@FreeBSD.org using -f From: "Simon J. Gerraty" Date: Wed, 22 May 2019 23:23:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348131 - stable/12/lib/libsecureboot/openpgp X-SVN-Group: stable-12 X-SVN-Commit-Author: sjg X-SVN-Commit-Paths: stable/12/lib/libsecureboot/openpgp X-SVN-Commit-Revision: 348131 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 7850D70527 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.95)[-0.951,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 May 2019 23:23:18 -0000 Author: sjg Date: Wed May 22 23:23:16 2019 New Revision: 348131 URL: https://svnweb.freebsd.org/changeset/base/348131 Log: load_key_buf do not free data from dearmor The data returned by dearmor is referenced by the key leave it alone! MFC r347980 Reviewed by: stevek Modified: stable/12/lib/libsecureboot/openpgp/opgp_key.c stable/12/lib/libsecureboot/openpgp/opgp_sig.c Modified: stable/12/lib/libsecureboot/openpgp/opgp_key.c ============================================================================== --- stable/12/lib/libsecureboot/openpgp/opgp_key.c Wed May 22 23:22:36 2019 (r348130) +++ stable/12/lib/libsecureboot/openpgp/opgp_key.c Wed May 22 23:23:16 2019 (r348131) @@ -168,6 +168,7 @@ load_key_buf(unsigned char *buf, size_t nbytes) initialize(); if (!(buf[0] & OPENPGP_TAG_ISTAG)) { + /* Note: we do *not* free data */ data = dearmor((char *)buf, nbytes, &nbytes); ptr = data; } else @@ -190,7 +191,6 @@ load_key_buf(unsigned char *buf, size_t nbytes) } } } - free(data); return (key); } @@ -209,8 +209,10 @@ openpgp_trust_add(OpenPGP_key *key) LIST_INIT(&trust_list); } - if (key) + if (key) { + DEBUG_PRINTF(2, ("openpgp_trust_add(%s)\n", key->id)); LIST_INSERT_HEAD(&trust_list, key, entries); + } } /** @@ -296,6 +298,7 @@ load_key_id(const char *keyID) if (!key) key = load_trusted_key_id(keyID); #endif + DEBUG_PRINTF(2, ("load_key_id(%s): %s\n", keyID, key ? "found" : "nope")); return (key); } Modified: stable/12/lib/libsecureboot/openpgp/opgp_sig.c ============================================================================== --- stable/12/lib/libsecureboot/openpgp/opgp_sig.c Wed May 22 23:22:36 2019 (r348130) +++ stable/12/lib/libsecureboot/openpgp/opgp_sig.c Wed May 22 23:23:16 2019 (r348131) @@ -318,6 +318,7 @@ openpgp_verify(const char *filename, sdata = ddata = dearmor((char *)sdata, sbytes, &sbytes); ptr = sdata; rc = decode_packet(2, &ptr, sbytes, (decoder_t)decode_sig, sig); + DEBUG_PRINTF(2, ("rc=%d keyID=%s\n", rc, sig->key_id ? sig->key_id : "?")); if (rc == 0 && sig->key_id) { key = load_key_id(sig->key_id); if (!key) {