From nobody Mon Jul 25 14:57:46 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 4Ls37G6FnTz4Xh8D; Mon, 25 Jul 2022 14:57:46 +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 4Ls37G5mB3z3Fpf; Mon, 25 Jul 2022 14:57:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658761066; 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=gUj7sOTbK8S9+Gy1FHCOaf/197tznn/laKuujnImNEk=; b=iRSrbHEIyos57RaAv61ryI2PHWkpR/Xt5+BT/i8qVXJm8AdAP6IUcFQNqtzU8UxF/PA6Zt 94LpStI3Vh0fLGgowiAyJQVPSUIikQJ3ZX65En19ceHIa5XYpOkPM0nU3PyuqXb5SMiiTi aWIhB9UY7fPLN9v7njcgoUVwUnYfPLc9kXkrJFQvN0k4nNzJ1a10jARhQ8T9AeZi3aL0lg iG7seVGWkddVW5cmMOOdcj97wDu/hnXynchDHt9hHv2WIwyPo3ak9jtzxJL7jQa2EgZ8Nm 24imxKEF9Zl63J1UA5MpoUZ9ZILipLX9nIYJt1QO3KPlR06rBCJkRv0yZOyqHw== 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 4Ls37G4gHyz11cR; Mon, 25 Jul 2022 14:57:46 +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 26PEvkl6001751; Mon, 25 Jul 2022 14:57:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26PEvkWl001750; Mon, 25 Jul 2022 14:57:46 GMT (envelope-from git) Date: Mon, 25 Jul 2022 14:57:46 GMT Message-Id: <202207251457.26PEvkWl001750@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: 35cdb601016b - stable/13 - blacklistd: Handle 0 sized messages 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/13 X-Git-Reftype: branch X-Git-Commit: 35cdb601016b2dbdb9f5e296ac4b5f42248eddf5 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658761066; 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=gUj7sOTbK8S9+Gy1FHCOaf/197tznn/laKuujnImNEk=; b=EzeW9HSBkoljPG6X9hiegnT7Qcp/uUe5B1gqN4pGUPybpfhR2XPJGqwhtje+rExpbLP6BS ecwKhZs4XwqIOzYG9BAjOeLeRpqi+MTgcfg/865vskdR+d9G0KwZMw6eel4DYGoMalMok3 OF/VxYRHxhuTYw2tsntTn+P7uYkRlu5YvoV9zjD1+3rVk4yLqjHKPeWqVEZkFsDQU6jwCy 88rcyf5pxEgL+8uvCzsY7i0VJEy/r5LVUj9ZhIbStBXiFXUoTnwObO9EXoI52rPYYvMvTy fmDaJ7S0QXmcyJ7ZGZr93upXPA7TvahglfgivFBnXV0wxZJXiP924D52nULwcA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1658761066; a=rsa-sha256; cv=none; b=wZGugQ8XU1zGGv0/ORKrX1PlLdlplDCK0cT3xGly+IKaUjViVPP3iQ639e6UOOzoh7cgXq FQaxda/7ShIHhKSaiQ1T0O6bkHSMC6GJ8apJmHfZoKbVsozz5sZaqX9Tu3jrU8VJvXgtZL OaeEzbe9BTzYDKPI2RUwxOlPmzyGO6Aq1c3QxWpcmUQUtg6jHp73qajs42QfFAiAXc7LET PK5nCZwC8ZfKTEAibJ3mJd7L4pF3BUkm0VZ9N2F6jN9EpflGtzE7hqJYN6szG2mfhdoF0e lIoC4cMb2mC4ksK79xjC420gkQaPBPYfTkuK/waG677jVqGOGREYud6Vupbmmg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=35cdb601016b2dbdb9f5e296ac4b5f42248eddf5 commit 35cdb601016b2dbdb9f5e296ac4b5f42248eddf5 Author: Ed Maste AuthorDate: 2022-07-18 00:43:52 +0000 Commit: Ed Maste CommitDate: 2022-07-25 14:57:24 +0000 blacklistd: Handle 0 sized messages Patch obtained from https://github.com/zoulasc/blocklist commit ada75856bc6fcabbdd25ffbe08fbad5cf2a2c08a PR: 264599 MFC after: 1 week (cherry picked from commit b1e81e6ddee42efb0f0d49cfc6cebb48d52e3f08) --- contrib/blacklist/lib/bl.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/contrib/blacklist/lib/bl.c b/contrib/blacklist/lib/bl.c index 9f93b91f4c8f..ab2bd7c43ebe 100644 --- a/contrib/blacklist/lib/bl.c +++ b/contrib/blacklist/lib/bl.c @@ -434,6 +434,7 @@ bl_recv(bl_t b) } ub; int got; ssize_t rlen; + size_t rem; bl_info_t *bi = &b->b_info; got = 0; @@ -504,10 +505,12 @@ bl_recv(bl_t b) return NULL; } - if ((size_t)rlen <= sizeof(ub.bl)) { + rem = (size_t)rlen; + if (rem < sizeof(ub.bl)) { bl_log(b->b_fun, LOG_ERR, "message too short %zd", rlen); return NULL; } + rem -= sizeof(ub.bl); if (ub.bl.bl_version != BL_VERSION) { bl_log(b->b_fun, LOG_ERR, "bad version %d", ub.bl.bl_version); @@ -521,7 +524,10 @@ bl_recv(bl_t b) bi->bi_uid = -1; bi->bi_gid = -1; #endif - strlcpy(bi->bi_msg, ub.bl.bl_data, MIN(sizeof(bi->bi_msg), - ((size_t)rlen - sizeof(ub.bl) + 1))); + rem = MIN(sizeof(bi->bi_msg), rem); + if (rem == 0) + bi->bi_msg[0] = '\0'; + else + strlcpy(bi->bi_msg, ub.bl.bl_data, rem); return bi; }