From nobody Fri Nov 24 14:10:45 2023 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 4ScH2F3TVCz52bH7; Fri, 24 Nov 2023 14:10:45 +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 4ScH2F2drPz3fh2; Fri, 24 Nov 2023 14:10:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700835045; 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=Ag6P2K9M5AMGPI34LfnIr7CCfiK12QEV9cU71bdCmeQ=; b=W2JpSFOuj+mOBdAB2PVjX+5TqA54dXiQ6plxtp2c0/TED72ev9PiV+3z+XQDCB7DR0wktc AK+tMDr3gDkOKMYbYIhnqAVhZh07PUDkUibTxFSOXJqPZMLDMFpXw3EE1vZNv1KRCVh23s rad2bOM5hGigOMoOwni/63eEJ18fLhv+IvJyBu/SZ9ExkVUc+Mqut0M+R5EpimL2TGqpqg oIR244/MZPGamM6kJ3OROPW4uiWRJ3RITCI6NgLGOcWG100c+W2hs7QEKhupVPRZWmC4D/ TSO5TG1W2aVZJKr+GJxdupjSe6JfNng+nMSbNCZ0kmVO7kg5GNAyjAtIqD68NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700835045; 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=Ag6P2K9M5AMGPI34LfnIr7CCfiK12QEV9cU71bdCmeQ=; b=MvF1DJiJBwS/GOEtbRmx4vnrYIzZnCRLT5PxpKnZHBOpifJ8x42v6KIV36TGrzTrkJBfoK ibufUHLWGMvjQTxTiW3uHqlxpUqx3WDJN9kKzzT+RcqAV3T2onwZvnSngRiEyOTWokVkhQ quj5imhXRvOGZFiFaEnTljj8i3UyzO9bD0ldZOi0SN1FVxdPr4Rch2E+CBYhkFl+ZU0r3T r7d35EZ39oHZt4zaUcuCfGnSv8UJoO5KAd184e0oAcuk68Qm90ELd9eBGCFQC1KuZA1B1G C5yviiM4cbNnzR1xtGxvSvpdl82TtZSu6SAr0Ouk56iQqD5bfK3pwdzp0dSEgw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700835045; a=rsa-sha256; cv=none; b=E7pRPSSXPw+u8SmkbcuysZiFKoHZpGuVmid9LJFjmCXr3j4fQydJzXHms+A1C4KfidyQFU 8VeozLdtgAmC+NAJtRPA6zihtbvNLqnpoYbVRbF8oleeCVuRY87lPJS/RIvOGIpuwYJVsB roPTXFJXuFNqdUC7MvYtK1MYvVFax60hq50Sla9Mw45zxcVq5z4rZvxu00raAhRu3fLtkw MrzwwBT0ObtutOIuPmPkX3zq7EMe9nJQhWrJHvjDN0IOJTKlgprE9Mb3AMisiE33/2usnQ Ye6AVrHDRMKcROh772Y/xypTTz4yzOvDTVGqEq1rB6+oOY1r70umQxenrjd0Yw== 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 4ScH2F1jqwzp1r; Fri, 24 Nov 2023 14:10:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3AOEAjXG024861; Fri, 24 Nov 2023 14:10:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AOEAjIM024857; Fri, 24 Nov 2023 14:10:45 GMT (envelope-from git) Date: Fri, 24 Nov 2023 14:10:45 GMT Message-Id: <202311241410.3AOEAjIM024857@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 3b0e5375ca85 - stable/13 - libpfctl: handle allocation failure 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3b0e5375ca85124a1684ae22b9ef5872ea0f5278 Auto-Submitted: auto-generated The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=3b0e5375ca85124a1684ae22b9ef5872ea0f5278 commit 3b0e5375ca85124a1684ae22b9ef5872ea0f5278 Author: Kristof Provost AuthorDate: 2023-11-17 09:14:59 +0000 Commit: Kristof Provost CommitDate: 2023-11-24 09:19:04 +0000 libpfctl: handle allocation failure While it's unlikely for userspace to fail to allocate memory it is still possible. Handle malloc() returning NULL. Reported by: Bill Meeks MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 33d55d0d0f33787e9e2796b5000be73af42573bc) --- lib/libpfctl/libpfctl.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 7fc22734994b..e5675f2a232b 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -71,6 +71,11 @@ pfctl_do_ioctl(int dev, uint cmd, size_t size, nvlist_t **nvl) retry: nv.data = malloc(size); + if (nv.data == NULL) { + ret = ENOMEM; + goto out; + } + memcpy(nv.data, data, nvlen); nv.len = nvlen; @@ -190,6 +195,8 @@ _pfctl_get_status_counters(const nvlist_t *nvl, struct pfctl_status_counter *c; c = malloc(sizeof(*c)); + if (c == NULL) + continue; c->id = ids[i]; c->counter = counts[i];