From nobody Fri Oct 07 14:04:39 2022 X-Original-To: dev-commits-src-branches@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 4MkVRq4Kf2z4dq9k; Fri, 7 Oct 2022 14:04:39 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MkVRq3MZxz3ryc; Fri, 7 Oct 2022 14:04:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665151479; 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=897jv/JegQBYBgKw3lRBQtVRza9dsDkmTWDUD5CsEFo=; b=WPdmSox0zZrXWwektgPjRsNkj0kFyqk+/k9DiK7B+R3DUvtb2kUXiwWgZVz+HACVyCT/bN 42zwFAxxeOajCOTnU8MdJsseMBaGy9yA2C9IxeRK2E7WFNODdGMmqpuBoW/Htq81ouPSwO IE8xqM+LUR1INh5Iu0Dk0bfUoEgCLo+gLcENL1oM93vZvflMr0QewDwZo5cGFnsJ0vNtny glWvBBM18AJ3rO+gk+GlapyPAvFGbPh0XzEgOWhwHKWO+sYGZZM0ISVXxlaStpTPsLk5kq iyrFeLNfqZ3MxgnO3Jkc9WE7Y3YOWUDJqY0/H9oIG1BlzaGk6Zw921DFrI7MJQ== 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 4MkVRq2Fvmzcvs; Fri, 7 Oct 2022 14:04:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 297E4d2q047872; Fri, 7 Oct 2022 14:04:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 297E4dFI047871; Fri, 7 Oct 2022 14:04:39 GMT (envelope-from git) Date: Fri, 7 Oct 2022 14:04:39 GMT Message-Id: <202210071404.297E4dFI047871@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: fb87708c51a4 - stable/12 - ssh-keygen: fix double free in error path List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: fb87708c51a4c6c6e10e77af84f77d0a77069f77 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665151479; 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=897jv/JegQBYBgKw3lRBQtVRza9dsDkmTWDUD5CsEFo=; b=Gk0uJBPYP8g0GALe6dnkqVcDRJkxnNk/Mhfwu2dwQ3FK56Vzr6bRPZT8DjARO+Kv9c2iWb 2aiDoaEdykByOWNRko+Lw/yfe9CY9nP8upEFGKKPRURO1WbIEj7gZMuhhLGRKgB7G/m06W gSAOOfcTEn3ntubGce5Jm0r6hdaSJ76UIWGsxJ2YaZMp7R0hcXH6v9eNPkKG1rBSA8TPvn Lj9BCXWOgosUAQDB8cPCAk+wjaVq2AP1ZTD3tGneyC9z8qytii0Ri//akGwoRzlzcUztLV GQoQ3fnX+4FNdu2eKC8w+JVAlJPmvUfDGe+Pwylk0P9QLtCRXnFEtCBgqWdGEA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1665151479; a=rsa-sha256; cv=none; b=gy6ve/ACWuJkEoVh6sKOb7jsN7lgp8W1TTAv0r9IyuVBOJ228Dr25fcIF3NF0Z/07LrhWE FrWZW8HmcKtB4cbZrk1ZapOFbuuzomDobqJY0tNgq+NM8AJyIHBczJBD3WYpNL0+p5ZK51 VW0bmq3MTr1Sfr511eYBkm4Akn40uvZV2cdjT4r27ZOE980iB4oCzJ559VIczT0tpBQAfa 85MOS9/gr0Q0fbbGYw1ld3J7qO7mYD/2n7R6PgoKAtH1C7hStS6+3IGSJT1aGIDgsuSMaI ldNZnLQpOJYmcZmR2GSC8hAReBUVdcJTVLM/jJi2CPWJjmM+fMvk1iPlElwa3A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=fb87708c51a4c6c6e10e77af84f77d0a77069f77 commit fb87708c51a4c6c6e10e77af84f77d0a77069f77 Author: Ed Maste AuthorDate: 2022-10-04 20:31:39 +0000 Commit: Ed Maste CommitDate: 2022-10-07 13:22:10 +0000 ssh-keygen: fix double free in error path From OpenSSH-portable commit 5062ad48814b, OpenBSD commit 39f35e16ba87. MFC after: 3 days (cherry picked from commit 666605ad2df3f5c1fb973dbd719ffbe3f3935c1d) (cherry picked from commit 02c646bb7288986912ad7bbe410636d0e257eda9) --- crypto/openssh/sshsig.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crypto/openssh/sshsig.c b/crypto/openssh/sshsig.c index 1e3b63982ba8..eb2a931e9c18 100644 --- a/crypto/openssh/sshsig.c +++ b/crypto/openssh/sshsig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sshsig.c,v 1.29 2022/03/30 04:27:51 djm Exp $ */ +/* $OpenBSD: sshsig.c,v 1.30 2022/08/19 03:06:30 djm Exp $ */ /* * Copyright (c) 2019 Google LLC * @@ -491,7 +491,7 @@ hash_file(int fd, const char *hashalg, struct sshbuf **bp) { char *hex, rbuf[8192], hash[SSH_DIGEST_MAX_LENGTH]; ssize_t n, total = 0; - struct ssh_digest_ctx *ctx; + struct ssh_digest_ctx *ctx = NULL; int alg, oerrno, r = SSH_ERR_INTERNAL_ERROR; struct sshbuf *b = NULL; @@ -514,7 +514,6 @@ hash_file(int fd, const char *hashalg, struct sshbuf **bp) continue; oerrno = errno; error_f("read: %s", strerror(errno)); - ssh_digest_free(ctx); errno = oerrno; r = SSH_ERR_SYSTEM_ERROR; goto out; @@ -549,9 +548,11 @@ hash_file(int fd, const char *hashalg, struct sshbuf **bp) /* success */ r = 0; out: + oerrno = errno; sshbuf_free(b); ssh_digest_free(ctx); explicit_bzero(hash, sizeof(hash)); + errno = oerrno; return r; }