From nobody Mon Jul 18 12:55:45 2022 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 4Lmhlj6grpz4T5dp; Mon, 18 Jul 2022 12:55: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 4Lmhlj654hz3p6C; Mon, 18 Jul 2022 12:55:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658148945; 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=WEcUi9BJUMj/MqzV63wEzxR6mmhVE61+kSiLw0QhUv4=; b=q7uUj+kauGlqX0xDHuq5c9BZ+Or+X7DadDCBYZecWQrx813GJap49stbvdPAJ+CNORMRrg 3skryZitYPmVT1gmM5cwXjzZCb5xL1Hw/RaB50zxnw4OOmobBhWNeiTdKEbFMMeFk/z+qt by91dEfFeZHhTbBrzdyYV+V2zqYxMAZb8R5WX+cgAU3G0FLnNIBnTRUESLV8BGRRhcRVYz FBSkHIGYh7UD6kUFg1gRzPBS0Vc32y7BqYHLRWOSg2e8Wg7Y/iGqYxjh5lcwnQTCjvSxh/ NEznN034hfmdxyjILLol7j3FIJM8GQcIxxEA/cgY1WwT0EQog3bdGTlwo3Alvg== 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 4Lmhlj564gzgGx; Mon, 18 Jul 2022 12:55:45 +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 26ICtjW1093455; Mon, 18 Jul 2022 12:55:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26ICtjX7093454; Mon, 18 Jul 2022 12:55:45 GMT (envelope-from git) Date: Mon, 18 Jul 2022 12:55:45 GMT Message-Id: <202207181255.26ICtjX7093454@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: b1e81e6ddee4 - main - blacklistd: Handle 0 sized messages 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: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b1e81e6ddee42efb0f0d49cfc6cebb48d52e3f08 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658148945; 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=WEcUi9BJUMj/MqzV63wEzxR6mmhVE61+kSiLw0QhUv4=; b=HJFOVOLnNaAtqzHCY/n5E+cC4ssJz/jDYE/HTB5L+5OSKZ1MjHb2kWJTIkHwgoYglYdCy9 ofoStxRC5nRKvFtz1s3KTHrE22eQ/8RA45VSCSbDJ5c1tAt5TyPXz0r2pmC6e/X80Ee6Ko hMlm9rxN7WohahrzabgEszsVwwz9sgn3BONZ7h+SkUWxWWs3N+y0BqJnwvwZ/nzr67SFPp NM60FscyW9kyIAg6QDf0mz2+N2LMIKQlMthk6+RLSMO8NUlIUldiI+Qi4cw0H48VDCGvI9 hBz4sfPHFZ5hP/6MugVSl+yICVE+bS4posWm3cR/zqRSHdj/3ZknDrItLohFkQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1658148945; a=rsa-sha256; cv=none; b=NpMahIAyDmYvH8LMkcJuUSpWG6JzDHA+s21ZT+QKRd/05hpJnxCzagy6liamQRgXl8Mx3g c3/eAqpEVLz1WvKbdV6gRBQIBYu/lcV9qbpULIUu1Kr2lEwNPGlMc4ufLtQzbqALpAVwt1 VBN0zKCyJm2ZKjKgz+m6SyOuTEXZwT3LGBcWizKC/wpPsOTQ5kkWqNhawjIi+puGPJ9TCo lAD+smPNtejltqkgax+f5h+gTL8keVqdQdOXnHjn/a6DQRr5D4mGY3ibBLhlnZV98xYQ12 GSXPBWKbpwP8ACNX17/0hDTIR/ygxqzyrcvfiFk9fCsgpEw2uqJYdXPyZXl3zQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=b1e81e6ddee42efb0f0d49cfc6cebb48d52e3f08 commit b1e81e6ddee42efb0f0d49cfc6cebb48d52e3f08 Author: Ed Maste AuthorDate: 2022-07-18 00:43:52 +0000 Commit: Ed Maste CommitDate: 2022-07-18 12:55:30 +0000 blacklistd: Handle 0 sized messages Patch obtained from https://github.com/zoulasc/blocklist commit ada75856bc6fcabbdd25ffbe08fbad5cf2a2c08a PR: 264599 MFC after: 1 week --- 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; }