From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 9258 invoked from network); 5 Jun 2023 07:12:06 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 5 Jun 2023 07:12:06 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1685949126; b=JlGRQf/QUcd8MOZL7L110deki7zY/Svq67RnNYs3EvIYIsOO3Rqo681ZRV/bFyfHjtLvCX7ato 4N7I6RRYGGurPe3mQDeQsvQhIU6ll6fVmUi6yzQIQKmRsqkwf3fgvcJMByJzoApDJuZRQlmiQV HCEPtqKh/RAnnX+KryS9Lrv9v5aQsBx5uzI4yjTYpVs5aJhgcXUY+K98hW9f89cpK58FwKDTtW MJ0ZICzsYNtKDLCl+Rdk0PxKRGRGWuZeoht1L98NYLRzrnB8RBQ/z3ZUCRKMi4/v7vq+j8B6Eq Yh1u2Da8vZ79Qk4/3zCESA+EqQZI/6bVSYNDLSVPQL4O+A==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (snd00002-bg.im.kddi.ne.jp) smtp.remote-ip=27.86.113.2; dmarc=none header.from=kba.biglobe.ne.jp; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1685949126; bh=O0CLUBQzGuZkPBOYiPl89QSjyLu4FS87Idha5R28obM=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Message-ID:In-Reply-To:To:References:Date:Subject: MIME-Version:Content-Transfer-Encoding:Content-Type:From:DKIM-Signature; b=Gvpxf7uGvZibMOJQKj06pnm1XcOsAHjZnrTQacgVF/c9+ki+UrMQbAincs4osmpCt/v3I2w2CB HCYuJN4ZRsAmDTLO6vWvDgddR+/jT19S4l5w2qhsKm7M6v8lCvsgTcqTG1O77j9EU5tvHeqx2L kZxKzDOLigk57ktkp8RDZxHsJZfnMktghM33zAqaa6XnxPjGeFI4bCTydTd1BYskQKzNY8wMyC ErQcnR9WnPmn0r12T8Wt1Y3gHe3O70a0zlbMWZ+7bPpusmeOXtD/QXuSLkTzdYNe16YNiMb4Qe 7jfO77b8VVg7OzbBiXJ7/bKiWRj99rEYANHpee/A0Ujb/Q==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Message-Id:In-Reply-To:To:References: Date:Subject:Mime-Version:Content-Transfer-Encoding:Content-Type:From: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=cNneKG9hELxYoRYeq/ZPVDUq91L12Qku5HVAOkt6pUI=; b=fjR9zb3fSBjelp4nRwcD+hziGu S9Rbvsn+vROKD/mrJXwh4h2cHw67lOwuPCLUMzAC3Vz2JbbiNbIG1nQc4xL2gHhofVSC5sS/m13Rl B22VCbxLeWM7Ko7y2/KPTSs3SLz9aOqEhnHaSN+E5Km0eQdvG3F5i8ItsBrXtC3UCvvQuOODldOm6 jXWUF17m7EZdkwYq1NqmNypSfCABKoUTgyCRTpTcDU1rJwZP1Bf0VDHtUPdIEkbdROmZqdBV3TFKQ FDF5woY5JYkfW5vbfRIXOOPeFS26FwenmNDn5OqTPoCFkNYGIffmeZX7tp252sukf/53y3xEas524 aSOsXR8g==; Received: by zero.zsh.org with local id 1q64No-000EgR-Py; Mon, 05 Jun 2023 07:12:04 +0000 Authentication-Results: zsh.org; iprev=pass (snd00002-bg.im.kddi.ne.jp) smtp.remote-ip=27.86.113.2; dmarc=none header.from=kba.biglobe.ne.jp; arc=none Received: from snd00002-bg.im.kddi.ne.jp ([27.86.113.2]:19553 helo=dfmta0026.biglobe.ne.jp) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1q64ND-000ENo-AJ; Mon, 05 Jun 2023 07:11:30 +0000 Received: from mail.biglobe.ne.jp by omta0026.biglobe.ne.jp with ESMTP id <20230605071120720.PHTG.87396.mail.biglobe.ne.jp@biglobe.ne.jp> for ; Mon, 5 Jun 2023 16:11:20 +0900 From: Jun T Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\)) Subject: Re: Bug: Null byte in shell history causes segfault during $historywords reverse subscripting Date: Mon, 5 Jun 2023 16:11:19 +0900 References: To: zsh-workers@zsh.org In-Reply-To: Message-Id: <644CEDDE-A281-4568-80A2-0462E6B5F089@kba.biglobe.ne.jp> X-Mailer: Apple Mail (2.3445.104.21) X-Biglobe-Sender: takimoto-j@kba.biglobe.ne.jp X-Seq: 51826 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: > 2023/05/27 4:37, Eric Freese wrote: >=20 > I've come across a segfault when shell history has been loaded from a > file and contains a command where a null byte was entered into the > line editor via ^V^@ (opposed to typing as $'\0'). Reverse > subscripting $historywords on a pattern that does not match triggers > the error. Is this enough? diff --git a/Src/hist.c b/Src/hist.c index 7e6394406..e2b4b0b22 100644 --- a/Src/hist.c +++ b/Src/hist.c @@ -3796,8 +3796,14 @@ histsplitwords(char *lineptr, short **wordsp, int = *nwordsp, int *nwordposp, zrealloc(words, nwords*sizeof(*words)); } words[nwordpos++] =3D lineptr - start; - while (*lineptr && !inblank(*lineptr)) - lineptr++; + while (*lineptr) { + if (*lineptr =3D=3D Meta && lineptr[1]) + lineptr +=3D 2; + else if (!inblank(*lineptr)) + lineptr++; + else + break; + } words[nwordpos++] =3D lineptr - start; } } while (*lineptr);