From nobody Thu Apr 04 08:07:37 2024 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 4V9DkK6hwsz5GWfg; Thu, 4 Apr 2024 08:07:37 +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 4V9DkK6D6wz4kR7; Thu, 4 Apr 2024 08:07:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712218057; 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=NQWFexs+XmzhDM91TIO0v9ZOYX9t6AtZ+lT2pfP5MvE=; b=GAQhs6gOUyuu2oM2zwH9hCZb2mEn4c+8tA04ccn7ZIEbgzQEEs50L504rxI48voKe9D/JQ wMWI7FxJKGVS7UmEw+iTNzp+WMdUwmtGa72V4zKuFwtkJLsGzrCFdoxFFyo1UkKMgCohKB eQCGUZFoVnh2Le+ctE32ZKZapIWDtop1/2krcW8Zdo7wxB3L+UhrN3wiRfz1ezGT6gJXHf M0cO3sGgSRfYG1xR1XYo6c3o8QsCHlJ8ewXARPPlTy4dvw9oKgnVMJOBLmnSvRCZjmx4wt IO0zolmMo2fxVN3cOswT7K/4FltV9TOo/TxHjDz08KAp+bSGPxi0Jvea9nK+EQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712218057; a=rsa-sha256; cv=none; b=Zv1BNlSuoSvzOiFzolAhoqC8d2IKHCyRFn/jTen1Z9JJBnHglPnPKwj/7hnVcYi4Ac5ZFR edXh1y1/cX0lAIrlYk4Eg41li8UBEUL+eU/AQ2SnF8klJJtAQwBtd3bk8+Noo99ZZyghe2 ynLyKv0EwJ8+ppzKZxMmD7jaQsU3LagGZicNbyoSy5UQ+5DWvYS9ZTifgCqq6SYUImgnsL QIuhAmI9r+aHzloiVPfWXIyZbhKaHbHSgNqkxz4yqkhdqYuOc10Z4s0POjrZzIhs0aRboH vdD5+pPkH5ktyvlQAiyZ8ex60ejbFIooSh1fj3CnB7sQRrDAxcmijQAuWJ6eKw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712218057; 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=NQWFexs+XmzhDM91TIO0v9ZOYX9t6AtZ+lT2pfP5MvE=; b=SHnRzLv5L3fk3R5xySSi3BHlqPhO14BdDNC4enkjYylt7Yo/xN9oCcFdqTsdgGWc7yD5dy 6xTX9asZuarEINN3Y+lZ8mi9TWNPsH+cx5mXgisu2T9qNeve8R4luWmnqrR9SvxjQx3BZx mj5YbMIQnuKGAVwCM36A4KwaXBWuNX7sHX0tpyhyw4RvYJjkI/UwXkUuQZYxSk8/Hk+YoY VAv/7KiyXYvDT2ixThsbTJKliYDsE/R1RXgthgmKGshvXsijRU0ym6ijg9R8jAABwyO3UL 0JsNhT37QOPDWtJ+0XMy9FT1BR7Y5Bm6pIVZlpIYmtNOPpCsYZIRAkuImzuIlw== 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 4V9DkK5r22z173G; Thu, 4 Apr 2024 08:07:37 +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 43487bOn004120; Thu, 4 Apr 2024 08:07:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43487b73004117; Thu, 4 Apr 2024 08:07:37 GMT (envelope-from git) Date: Thu, 4 Apr 2024 08:07:37 GMT Message-Id: <202404040807.43487b73004117@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: 4848eb3af2a9 - main - tcpdump: cope with incorrect packet lengths 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: 4848eb3af2a91b133c4b70cb9b71dd92ffec7f46 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=4848eb3af2a91b133c4b70cb9b71dd92ffec7f46 commit 4848eb3af2a91b133c4b70cb9b71dd92ffec7f46 Author: Kristof Provost AuthorDate: 2024-04-01 09:42:14 +0000 Commit: Kristof Provost CommitDate: 2024-04-04 08:07:05 +0000 tcpdump: cope with incorrect packet lengths It's possible for the capture buffer to be smaller than indicated by the header length. However, pfsync_print() only took the header length into account. As a result we could read outside of the buffer. Check that we have at least the expected amount of data before we start parsing. PR: 278034 MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D44580 --- contrib/tcpdump/print-pfsync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/tcpdump/print-pfsync.c b/contrib/tcpdump/print-pfsync.c index 5710e36ded6c..6bf9abaf3903 100644 --- a/contrib/tcpdump/print-pfsync.c +++ b/contrib/tcpdump/print-pfsync.c @@ -86,7 +86,7 @@ pfsync_ip_print(netdissect_options *ndo , const u_char *bp, u_int len) { struct pfsync_header *hdr = (struct pfsync_header *)bp; - if (len < PFSYNC_HDRLEN) + if (len < PFSYNC_HDRLEN || !ND_TTEST_LEN(bp, len)) ND_PRINT("[|pfsync]"); else pfsync_print(ndo, hdr, bp + sizeof(struct pfsync_header),