From nobody Mon Jun 3 09:50:43 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 4Vt89b1kGfz5MD8q for ; Mon, 03 Jun 2024 09:50:43 +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 4Vt89Z6x1lz4LBm for ; Mon, 3 Jun 2024 09:50:42 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1717408243; a=rsa-sha256; cv=none; b=I71CYdD6Lf51MPk1xbH0n7yituc4Svh72HlNiBVIhsCrLGeMxQrDiSGAAkstILE3U2mzWq Z9cHovmek5WPOSsTpEmDNXVFLTHoN1M/NFr0LiO7x8fChD4lpSd2GM/Ca70wa76U2N+wTq EaPZpXTOx5LXHULYlA0avtYk8Wbe7rzt/ZXICeeZbsUyAM9dUcHKsgjcZXjE8J2ZeWPJ4P 865puSBIw+WSBxjGNMoPhsWH06W+lu44zOkh9Gu0nwn5Cg2pnLBggPLGwRuD6nsMeohC29 ZuAzffVQH6wztohhekFzlaX9oR1XzBb23sHe1AYpx77v5GaA7+/0a34RXoQhnQ== 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=1717408243; 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=828PbAlNV3T6LNi6DMVmeQQoAU5a/TYn0KQbPtRY99A=; b=fuWFNomfq/VaXJa3g6TE7DINdTyvCP/sCYNX8YdvmMizYlZW8MKoCIBbs+5VD0fNFyYnMR K6ImbjnhCJWJqSaZMRpdfj0nGXMVFQUcpwK3v60DQbaYpCCkIPe2jxqgjdJjQXW89DsAkJ p4V9abZ4vq9PfV79/deJbzv86f+Nmt+Y++PEnVDIhzJ7Ssh9t6D8+qT0fNQCdz5o58TZC8 7xobSdtz7RfnIWRwaXD/rswEMPjKE1tWcJPHkUcrZdf5pAw3KUF3nb6t1HLl4/aL+IbHdL SZ/1BlSTm2tXoAm2f5RECupQiLE7l9hgc7A80OXmbi/NaX95ZR5ZAtBLlZ+tbw== 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 4Vt89Z6XX1zVnH for ; Mon, 3 Jun 2024 09:50:42 +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 4539ognn032813 for ; Mon, 3 Jun 2024 09:50:42 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 4539ogPF032807 for bugs@FreeBSD.org; Mon, 3 Jun 2024 09:50:42 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 279487] ESC [ F can cause libedit to read/write before start of buffer Date: Mon, 03 Jun 2024 09:50:43 +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 Only Me 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=3D279487 Bug ID: 279487 Summary: ESC [ F can cause libedit to read/write before start of buffer Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: rtm@lcs.mit.edu This code in contrib/libedit/common.c: ed_move_to_end(EditLine *el, wint_t c __attribute__((__unused__))) { ...; el->el_line.cursor--; causes el->el_line.cursor to point before the start of el->el_line.buffer if the current line is empty. Then subsequent commands that read or write via cursor use the wrong memory. For example, if I run valgrind /bin/sh and type $ set -o vi and then (on a new line) ESC [ F x valgrind says Invalid read of size 2 at 0x4854920: memcpy (vg_replace_strmem.c:1163) by 0x487312C: cv_yank (rtm/freebsd/contrib/libedit/chared.c:90) by 0x4873652: c_delafter (rtm/freebsd/contrib/libedit/chared.c:129) by 0x4875E67: ed_delete_next_char (rtm/freebsd/contrib/libedit/common.c:178) by 0x4889747: el_wgets (rtm/freebsd/contrib/libedit/read.c:540) by 0x4879B3C: el_gets (rtm/freebsd/contrib/libedit/eln.c:75) by 0x123D6E: preadfd (rtm/freebsd/bin/sh/input.c:138) by 0x12387A: preadbuffer (rtm/freebsd/bin/sh/input.c:210) by 0x1326C5: xxreadtoken (rtm/freebsd/bin/sh/parser.c:910) by 0x12E4FC: readtoken (rtm/freebsd/bin/sh/parser.c:827) by 0x12E379: parsecmd (rtm/freebsd/bin/sh/parser.c:222) by 0x129786: cmdloop (rtm/freebsd/bin/sh/main.c:206) Address 0x552549c is 4 bytes before a block of size 4,096 alloc'd at 0x4851735: calloc (vg_replace_malloc.c:1599) by 0x48740AA: ch_init (rtm/freebsd/contrib/libedit/chared.c:399) by 0x4877714: el_init_internal (rtm/freebsd/contrib/libedit/el.c:107) by 0x48775B0: el_init_fd (rtm/freebsd/contrib/libedit/el.c:124) by 0x487754A: el_init (rtm/freebsd/contrib/libedit/el.c:66) by 0x1215BC: histedit (rtm/freebsd/bin/sh/histedit.c:183) by 0x12C1ED: optschanged (rtm/freebsd/bin/sh/options.c:130) by 0x12BEA1: procargs (rtm/freebsd/bin/sh/options.c:121) by 0x1293EC: main (rtm/freebsd/bin/sh/main.c:131) Invalid write of size 4 at 0x487368A: c_delafter (rtm/freebsd/contrib/libedit/chared.c:136) by 0x4875E67: ed_delete_next_char (rtm/freebsd/contrib/libedit/common.c:178) by 0x4889747: el_wgets (rtm/freebsd/contrib/libedit/read.c:540) by 0x4879B3C: el_gets (rtm/freebsd/contrib/libedit/eln.c:75) by 0x123D6E: preadfd (rtm/freebsd/bin/sh/input.c:138) by 0x12387A: preadbuffer (rtm/freebsd/bin/sh/input.c:210) by 0x1326C5: xxreadtoken (rtm/freebsd/bin/sh/parser.c:910) by 0x12E4FC: readtoken (rtm/freebsd/bin/sh/parser.c:827) by 0x12E379: parsecmd (rtm/freebsd/bin/sh/parser.c:222) by 0x129786: cmdloop (rtm/freebsd/bin/sh/main.c:206) by 0x1295D2: main (rtm/freebsd/bin/sh/main.c:167) --=20 You are receiving this mail because: You are the assignee for the bug.=