From nobody Fri Nov 17 12:21:25 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 4SWwxL2q42z50vXy; Fri, 17 Nov 2023 12:21:26 +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 4SWwxL0brCz3P6F; Fri, 17 Nov 2023 12:21:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700223686; 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=sSvrsWZc5H/V1ffDXpwZLOG6X8QHdUqzS+jeFUBlOUo=; b=CDgxeRpLVrNDGqZm7jKxCE4zVFFiLQ7nSzK3f4UoEK8t9pVuIwAX4pdIwaT8evyzXnwGIV Hc1y1urN39AXt6YzYd5X6PHDpRyMDj67DOPpxi+OGc8nEgOYSyyRIL9TojLS6gEhudGu35 7fwfBZhD1Kbo9GK6INmm5LfnH+aKB4ceF4sB4QwKCnOYD3xAdKrSVND/JUcU8LVmzeHSoG dAgDy3th50mz8oOGaV5gZ6N8IkN9UnjBZM7Z9EFvKUX1hkZ6ZrqR/SGAd4LLfkej556wA8 lABzHSy40W57w/pyFwnCPn2K9FaZhPWD9I9dSnZf5zuTA19+icsoC5olTewGtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700223686; 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=sSvrsWZc5H/V1ffDXpwZLOG6X8QHdUqzS+jeFUBlOUo=; b=gMSiuP8zCNbgunN2aIt7/2oHYRrAx6oX/DfzEjg4w3sByEwR4ZSpP97Bv4/xHCkmtPQjXi 0TXXYK9tKmMWcxxzEHySPPz6NvkScKo/yNAq0HtK4DoCeQqNw/G11+ci6V/ZvlA3npdt7y 5ZRZNbz8ftgsR0l76YTBvC+I/JS2zYHN90HJEUC3mwf9YRF5o+r8E/yBPmXVUdTRT9NHei JSZgMphGRehLfK9KX6Gpiz0cGby8PUjLmlY6t/U+4uGb48C0LM68ZbvfHG+yrJcOr7x01a neH0lfn/hFeMRC/+TCrGBQhIe6WyQp6kbBbUCyJjV0HQjXhhh+xmbkxyyNUHgQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700223686; a=rsa-sha256; cv=none; b=g9RK3c2BKIGAXWaO6pH1Iv3bc3PoPzcFqO76DiDONlxC/KlNlEIP2jckVE9ynZUsm4YDDH bAngfVTeMWOT2GcsK7VDHhHRB+zQelvKmrzW1+5Xdv3YuV59XKD6+7FtyMIuUZT+MTnI07 xCf0HnGIlASLsTSvGCQKL641F36+lbA3AdNgb56yoBA9VVngEbRRepV7kK92URaoYgfKQW g6r1mG89xVz+8IU9LsWoo3v0BFJIZozTHjLlWlFPvjxcKUKF5CkLuI5pcktrSt3Xh0gde7 kHWuCtlHb3xCNYHjuhRW+yIY5Lfk6CJD6zCn12lr1h72CC6vGhrIqSu7yRtoNw== 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 4SWwxK6pBdzjf5; Fri, 17 Nov 2023 12:21:25 +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 3AHCLPNF002157; Fri, 17 Nov 2023 12:21:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AHCLPR9002154; Fri, 17 Nov 2023 12:21:25 GMT (envelope-from git) Date: Fri, 17 Nov 2023 12:21:25 GMT Message-Id: <202311171221.3AHCLPR9002154@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 33d55d0d0f33 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 33d55d0d0f33787e9e2796b5000be73af42573bc Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=33d55d0d0f33787e9e2796b5000be73af42573bc commit 33d55d0d0f33787e9e2796b5000be73af42573bc Author: Kristof Provost AuthorDate: 2023-11-17 09:14:59 +0000 Commit: Kristof Provost CommitDate: 2023-11-17 12:21:14 +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") --- lib/libpfctl/libpfctl.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 41ac2892a5a6..be794c6d3f34 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -78,6 +78,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; @@ -229,6 +234,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];