From nobody Sat Mar 18 14:02:55 2023 X-Original-To: dev-commits-src-main@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 4Pf2l33YJZz3ycY6; Sat, 18 Mar 2023 14:02:55 +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 4Pf2l331mPz4FFc; Sat, 18 Mar 2023 14:02:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679148175; 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=9G6zUXNnwVv9Yvtcbojz3/DYDFsb8JYghAUmyMQVTJI=; b=NPipmIcf+6QqOkUq8FnVM8s0ao7JhMAPhRQG6206fAkzmZxrOtDSFEVAII0VVlAA5ZvPW1 nIfgz9G2DXrv4g85j5j78k3k2vuEzFJUadN1uJqS5/TQXAt+j38rdJNZVW/5ia8/KyrhW2 3ATyMddFyQgU5791rGepyfvX4T5s5Yta4fLg2blxHCASHySmMVmANAcI/REr8DgsMD5jrb DapAsPC5/yNYERyJTXKmPYY8t9FmM60aw/BORKdRTRuo+DH2aw0SJx4XSbffrMqBdkKL40 zzKlK2Gt/gJFrEcxR+pw42EJfY9xArnylWutaLIgyfxtC5mNfiYkPR4FszFNpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679148175; 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=9G6zUXNnwVv9Yvtcbojz3/DYDFsb8JYghAUmyMQVTJI=; b=lD5aL+h00NgUFloit/Ag4w++vFfFRZzZZ8vPVg9NpsQ0jmElh6zpKNXoqQAhrEuabkb50/ FbcOXkmYp8LMB6C+/LoMhoTEf7Bq65zI0Hb2Qilzz1d21NrfBITnGeW/VVg6kYcoMeQOQG MdSjY+j6LF6V7IbCl7lcpu8t4ocvhbqJv44pGVKEFCiOD5UiqxMZm6sTENskbLjriGiMzh ro/7Cciy2eJ5sDdGtbbcK753SYC3RdeyltthBRierI/XI5e1Kpqr7LR9MGLcJnuhp7d5gn 4jwNgLXFZQHTvOwdzfu6Bhtc1KA0rOTjZzLsmX6dEYue9W0sC5M41Q5sSXe9gQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1679148175; a=rsa-sha256; cv=none; b=Xqp8pVgDYhqhRhsxfl2rVkocLSWQ4JCspYT0MDDibcpDbDx+kQ6YFbxsOj0vatcq0YEI7L JV05SkQiHYVH80nCsp4lSRUY5Hw3ExZ2DFqy15NER5bDVLafBi4aOCQByP4y1zzUky2JrM EsRMPw89HMhqNoxOaxyn0LIAEDlZFiXqvt384ZDEaiWg1FJey3DoGCx5L6xEo3bjlvSpPv zlH1eQRXCLXNVDpJoSF+PbXFOZ/O4KNASWoYlZ/cojs8BrGGzR3m1ekxVQkQKN06QU79n3 H4UPYFJXenfIRSTzxFfIgNu4jhFv5+i9seE060eEjrH5JlSQ/5HErC+iGe5KuA== 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 4Pf2l324n3z18vX; Sat, 18 Mar 2023 14:02:55 +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 32IE2tCC093939; Sat, 18 Mar 2023 14:02:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32IE2tdR093938; Sat, 18 Mar 2023 14:02:55 GMT (envelope-from git) Date: Sat, 18 Mar 2023 14:02:55 GMT Message-Id: <202303181402.32IE2tdR093938@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: 9ee6278b7885 - main - netstat: fix double-free in netlink error code path. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9ee6278b78859e8a9e303ec4a037b4e76d6ed89a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=9ee6278b78859e8a9e303ec4a037b4e76d6ed89a commit 9ee6278b78859e8a9e303ec4a037b4e76d6ed89a Author: Alexander V. Chernikov AuthorDate: 2023-03-18 14:01:46 +0000 Commit: Alexander V. Chernikov CommitDate: 2023-03-18 14:01:46 +0000 netstat: fix double-free in netlink error code path. CID: 1504382 --- usr.bin/netstat/route_netlink.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/usr.bin/netstat/route_netlink.c b/usr.bin/netstat/route_netlink.c index 3546603ca1cc..6e7e505c9619 100644 --- a/usr.bin/netstat/route_netlink.c +++ b/usr.bin/netstat/route_netlink.c @@ -91,10 +91,8 @@ prepare_ifmap_netlink(struct snl_state *ss, size_t *pifmap_size) }; msg.hdr.nlmsg_len = sizeof(msg); - if (!snl_send_message(ss, &msg.hdr)) { - snl_free(ss); + if (!snl_send_message(ss, &msg.hdr)) return (NULL); - } struct ifmap_entry *ifmap = NULL; uint32_t ifmap_size = 0; @@ -286,6 +284,10 @@ p_rtable_netlink(int fibnum, int af) return (false); ifmap = prepare_ifmap_netlink(&ss, &ifmap_size); + if (ifmap == NULL) { + snl_free(&ss); + return (false); + } struct { struct nlmsghdr hdr;