From nobody Thu Apr 25 13:43:38 2024 X-Original-To: bugs@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 4VQHBP4YxVz5HlY8 for ; Thu, 25 Apr 2024 13:43:41 +0000 (UTC) (envelope-from bugzilla-noreply@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 4VQHBP2v6Qz42Q6 for ; Thu, 25 Apr 2024 13:43:41 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1714052621; a=rsa-sha256; cv=none; b=aD4zuH+NWMdyA+/0jzmE33QHSVhYD6CjJZrfdYSc52d8vkaPe4cbwRM4PybQrA9pGDObJ+ A7v7Oh6p4dsq46R393qbHdle/8u/IDDK/4km1PFfz2K8C8Cv22+axTVcu4O5BzeB5Gj2ex BNW1dOgHux90f3yDaX09q7ILHTBwdFz+V7FvKPeuCvqbCPd4ANfVK9oywPIm/SNMwrFnBO zmmBVH2HZUdvkiaB8U/LQIWnR3J5PMa3i1BAAEXkr5RjjmxAIoluMFI+VuwzPn/kYRUEeP 9+YdVmogoh48OiEQjVCn3OnkdYMzhUuLzP5HO0jFaNRSKF0fG0P7X06FQRTtuw== 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=1714052621; 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=toeJR7QIOnChhoqGyE1vkSuausAcJt3Vkj+N9rPESRo=; b=F7XM37LfkC++F1BdAsj8pcCbmNjFO4E+FnSREuGxI3wi54kV8qiGPG31fU0Qu5E2JFfOwS 0M7D3jw6+FM0kIgXSxhi7otEBSZVxkeJVYDXhnrvBk/iS2MLcUMFISNSNJVo6UaJz07NgY nq1v9b2BhHXKFmmaAYc22EKNS2Nj0t6ik1GRhZ3l1KbcwiOt21CvPMfk06C6S60rHKaUzq o1AOTlqEcuigGUDP5CgkFT/2wI4jebmexuFDmRRduC535Z6gjAf6jGJHOaEb+aMF9p70mj uMp6yEbPUrO8tDRXfsiK1Fg+LWRGevSy4HdMkyAkIbNCnaqFuyG6qnIYBqf5Mw== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (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 4VQHBP2VcJz11lS for ; Thu, 25 Apr 2024 13:43:41 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 43PDhfeH076154 for ; Thu, 25 Apr 2024 13:43:41 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 43PDhfIx076150 for bugs@FreeBSD.org; Thu, 25 Apr 2024 13:43:41 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 278579] nvi can malfunction if one types invalid UTF-8 Date: Thu, 25 Apr 2024 13:43:38 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: rtm@lcs.mit.edu X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@FreeBSD.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D278579 Bug ID: 278579 Summary: nvi can malfunction if one types invalid UTF-8 Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: rtm@lcs.mit.edu If LANG is set to C.UTF-8, then typing illegal UTF-8 in nvi can cause v_event_get() to access elements in gp->i_event[] even though gp->i_cnt is zero -- that is, elements that have not been properly set. Here's how this can happen. v_event_get() calls gp->scr_event(), which is cl_event(). If the input is bad UTF-8, cl_event() sets evp->e_event to E_STRING, evp->e_len to zero, and returns zero (no error). v_event_get() calls v_event_append(), but since e_len is zero, nothing is put in gp->i_event[] and gp->i_cnt is not incremented. But the code goes on to use gp->i_event[gp->i_next], even though that element wasn't set. Another consequence is that v_event_get() calls QREM(1) before returning (line 670 of common/key.c), but since i_cnt was likely zero, QREM()'s decrement may wrap i_cnt to a huge unsigned. Since i_cnt can now incorrectly be > 0, v_key()'s next call to v_event_get() can incorrectly return whatever happened to be in gp->i_event[0], and if it's not valid, the abort() in v_event_err() may be called. You can see the abort() by setting LANG to C.UTF-8, running nvi, and typing a pair of characters with high bits set that aren't legal utf8. On my keyboard, I can type option-u option-i, which generates 0xf5 0xe9. Perhaps this can be fixed by 1) goto retry in v_event_get() if gp->scr_event() returns an E_STRING with e_len =3D=3D 0, and 2) set clp->skip =3D 0 in cl_event() on Invalid input, to reset the UTF-8 parsing state. But I do not understand the code well enough to be sure. --=20 You are receiving this mail because: You are the assignee for the bug.=