From nobody Thu Sep 03 07:59:15 2026 X-Original-To: dev-commits-src-main@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 4hbBnc2Wnhz6qrJy for ; Thu, 03 Sep 2026 07:59:16 +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 "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hbBnb73DBz3Xq3 for ; Thu, 03 Sep 2026 07:59:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1788422356; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=IwOLigb0p/pplRCwmGvgbBGamslpIsD9DNWScsEqZxA=; b=LxUnyyKpsjCLf+w6AatZkjuEMkyGE13FAvcfy5Lgk5tieemGiERLP+sm/y6Czp6eQ6z4T+ QNDqkAyFV4Iazt1pEUWD8GnidSy8iDiPIn2OpPmQR4cclV5hVY2MttWqnv7LTvIh0yu3XM T5shlSChosZTgn6bYb3ou+GaZHklsGGfatGSbi89zJFXB7RBjwd0FE9A6LlrCXEHF0elOR zzOwLfYMSI4NBpOklybWOY7ZvBqHq2F9a9DGMhkwcW7/s7MqVH6p6BL+pXhvPSSswLjNZS 8Nt8flEM5tff7t0tODfzyTEdHuhFblq0oI3XVW+4i/qBNcnvokaTqxoh/K1OuQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1788422356; a=rsa-sha256; cv=none; b=pP8n6jZzjghhXVwm0srCoNjJ46ayYfS0m5a7xPXjAsUZPWoiEH14tjrpLqmeXT1kikpfsU mutgK5Mjy7Pbqo0xrrC6tVJaxesg0wv8V/HFXug4NbMSzVhNx0NWJPNqa7fS+DRmfBcC9b gDJEYC5NZWDW4iAcHUq4SzM/TLRQaO4JkK4YgQnPcQyLofdet6WByuZxc2Sb/vuySo9e8s CTqK1oKBzHQZeKTLVQyJLHFA6felwJadIEUCv4eS5/mXNhnNZi/IIN5UGkx0mbZHRNqdW4 FrztwIP0jfYKedldikCGS6v+xZroS54DjYU7ZmpCfdMqft+TK6O6JfNLvGt7LQ== 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=1788422356; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=IwOLigb0p/pplRCwmGvgbBGamslpIsD9DNWScsEqZxA=; b=pxil3gnFvvpKCSnMqCdg4Vtci/iXcN4WmdR+/IjTav15ei96kUbilmSO0GV2TkwQ8gnaIA rqIzrZiEbDTJ90/1yQfvW2n3k2SHA+mzo0Rn0NYmNP+eDpkzub9mtxXcwmtCXzaCM5D3rk 29xje8SGY4+hHhRuEgXKCokEpXf8uil+go8v94C6Kr6tbEWDhJydub3kjpsndF985b6QvY kf9DnOH2vToWcY5y42WoywvnCZgWAyznRlDC7GX5qvt35VgFs2c3IIkpiXMi8khRLP1wie VBmsEQrJLKAFskcEKo6xc9/2ROElQoFQjZF5JZYMJvtrb+4CQd42AZy/M9yXZA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hbBnb5KXTz1KLY for ; Thu, 03 Sep 2026 07:59:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 212f2 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 03 Sep 2026 07:59:15 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Glen Barber From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: 8646d65b4533 - main - hastd: Fix crash on empty message List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8646d65b45339642d4aab1de35a2bc79fc45f09e Auto-Submitted: auto-generated Date: Thu, 03 Sep 2026 07:59:15 +0000 Message-Id: <6a9928d3.212f2.16eadf76@gitrepo.freebsd.org> The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=8646d65b45339642d4aab1de35a2bc79fc45f09e commit 8646d65b45339642d4aab1de35a2bc79fc45f09e Author: Glen Barber AuthorDate: 2026-09-03 07:51:28 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-09-03 07:58:54 +0000 hastd: Fix crash on empty message A HAST message can be empty, in which case ebuf_add_tail() does nothing and ebuf_data() returns NULL because the size of the ebuf is zero, but hast_proto_recv_hdr() asserts that the return value is not NULL, resulting in an immediate crash if hastctl or hastd receive an empty message. This is trivially reproducable by running `hastctl status` or `hastctl role init` (as the rc script does prior to stopping hastd). To avoid this, don't try to grow the ebuf or receive additional data if the header size is zero. PR: 298085 MFC after: 3 days Reviewed by: kevans, gjb Differential Revision: https://reviews.freebsd.org/D59306 --- sbin/hastd/hast_proto.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sbin/hastd/hast_proto.c b/sbin/hastd/hast_proto.c index d9f231e7b007..fc90bf59dc8a 100644 --- a/sbin/hastd/hast_proto.c +++ b/sbin/hastd/hast_proto.c @@ -150,12 +150,14 @@ hast_proto_recv_hdr(const struct proto_conn *conn, struct nv **nvp) eb = ebuf_alloc(hdr.size); if (eb == NULL) goto fail; - if (ebuf_add_tail(eb, NULL, hdr.size) == -1) - goto fail; - hptr = ebuf_data(eb, NULL); - PJDLOG_ASSERT(hptr != NULL); - if (proto_recv(conn, hptr, hdr.size) == -1) - goto fail; + if (hdr.size > 0) { + if (ebuf_add_tail(eb, NULL, hdr.size) == -1) + goto fail; + hptr = ebuf_data(eb, NULL); + PJDLOG_ASSERT(hptr != NULL); + if (proto_recv(conn, hptr, hdr.size) == -1) + goto fail; + } nv = nv_ntoh(eb); if (nv == NULL) goto fail;