From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#29918: 26.0.90; serial-term error in process filter Date: Thu, 18 Jul 2019 07:22:10 -0400 Message-ID: <874l3jzixp.fsf@gmail.com> References: <87y3liwr80.fsf@runbox.com> <87d0icy03x.fsf@mouse.gnus.org> <87sgr7ottd.fsf@runbox.com> <87ims19bbo.fsf@mouse.gnus.org> <87a7dczyd9.fsf@gmail.com> <83pnm7ybmf.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="136849"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2.90 (gnu/linux) Cc: 29918@debbugs.gnu.org, gazally@runbox.com, larsi@gnus.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jul 18 13:23:08 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ho4V9-000ZO7-AP for geb-bug-gnu-emacs@m.gmane.org; Thu, 18 Jul 2019 13:23:07 +0200 Original-Received: from localhost ([::1]:36542 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1ho4V8-0005yk-4J for geb-bug-gnu-emacs@m.gmane.org; Thu, 18 Jul 2019 07:23:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48939) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1ho4V5-0005yX-OS for bug-gnu-emacs@gnu.org; Thu, 18 Jul 2019 07:23:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ho4V4-00034I-N2 for bug-gnu-emacs@gnu.org; Thu, 18 Jul 2019 07:23:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44686) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ho4V4-000343-Iw for bug-gnu-emacs@gnu.org; Thu, 18 Jul 2019 07:23:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ho4V4-0001fA-BE for bug-gnu-emacs@gnu.org; Thu, 18 Jul 2019 07:23:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 18 Jul 2019 11:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29918 X-GNU-PR-Package: emacs Original-Received: via spool by 29918-submit@debbugs.gnu.org id=B29918.15634489436332 (code B ref 29918); Thu, 18 Jul 2019 11:23:02 +0000 Original-Received: (at 29918) by debbugs.gnu.org; 18 Jul 2019 11:22:23 +0000 Original-Received: from localhost ([127.0.0.1]:53507 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ho4UP-0001e2-Q7 for submit@debbugs.gnu.org; Thu, 18 Jul 2019 07:22:22 -0400 Original-Received: from mail-io1-f53.google.com ([209.85.166.53]:33483) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ho4UN-0001do-3Y for 29918@debbugs.gnu.org; Thu, 18 Jul 2019 07:22:20 -0400 Original-Received: by mail-io1-f53.google.com with SMTP id z3so50874312iog.0 for <29918@debbugs.gnu.org>; Thu, 18 Jul 2019 04:22:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=1cfoe2LPvob/yv3Y0hMH7vQ0xtOjEqdIo+zIc+Ngo24=; b=nuKLA6y9QHeQyZAazbjYOXsE1n251/LRHc1ctd2oEkLMKUDVFPJr0c8skejhuoBpS3 6Pm/iMAEfwe67kEPdqALoZBpLmu01Tj3P2Nebwx4yqNNLMNz2NFTHJeLNQw9bJHSVwdC 53Eqe6kmdQKSZPquf8z3dAmXA8NYcvPZl/IJ+ZjPVQbyvNMb03vXMolvEzFaMWy/yFzg XrNbDewS5avKkM71TwZ7gd6YlunMPISs4T0o6Dx9zRfpTq7oI5zd6VnvNzM6e8hlDtav l4k3afxr3oByOjs3YCC3C3wciARNuE9ZGOWljimn0q50i23+3kVLc+M3UivavpHo3V7z jFvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=1cfoe2LPvob/yv3Y0hMH7vQ0xtOjEqdIo+zIc+Ngo24=; b=g5RMCpdTF7oQRVsYly5mT1F66VAqHE/YBumLSgGX/81+PWHv4minZKkwPMcAivlE4V tbsjs7U0tFrWEghOvFEJHEy184nASVjyqAlweGGXQM9j1r2MXqZZYoIbxtHNGLQr5mzA nBWCX0xGQNoS+P6vhO2rjdGUZR4QDELQhOyJ5ykNh8D1uxnoVa/XuSjSGb1rBbsxyXen G0ZTrWkVddBYpN1Cp5Bb5YR3SlRi5jYI7DLO1fFX1o/wrYoSQAVTVcuU9wUJ50N4BZJe 4gkhw2qGj8+K/OSuI+kLMh9MiZDXL0NesaPTKLOLQ/eNuCP6zE9ts/iXoAihO+FG9FaO 3Ekw== X-Gm-Message-State: APjAAAUqt2YO/30IbPSl6qVvlxYvJ0hgQKzWpiQJ8AvtyQebepvb2l86 NSha9mkOexZvr2gBaw+0gts= X-Google-Smtp-Source: APXvYqxyKiDx3IB9I+4N9HgpDaqbLV8ImWHQUnIbHq2htm2Z2TlNcUew+Z8pJFdYKeoe9ATxfe1IYw== X-Received: by 2002:a6b:3102:: with SMTP id j2mr30878302ioa.5.1563448933462; Thu, 18 Jul 2019 04:22:13 -0700 (PDT) Original-Received: from minid (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.gmail.com with ESMTPSA id m10sm45167803ioj.75.2019.07.18.04.22.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Jul 2019 04:22:12 -0700 (PDT) In-Reply-To: <83pnm7ybmf.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 18 Jul 2019 11:45:28 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:163290 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> there is a possibility it prevents correct decoding in case the >> terminal receives a utf-8 character in single byte chunks (though >> I'm not sure if it's even valid for a program to emit single bytes >> like that). > > I agree. I thought of limiting partial to 4, to avoid this possibility, since utf-8 characters can be 4 bytes at most (not sure about other encodings though). --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=0001-Handle-completely-undecoded-input-in-term-Bug-29918.patch Content-Description: patch >From bad839ca47ac58bd4967b95f447a596940e832f1 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Wed, 17 Jul 2019 07:20:20 -0400 Subject: [PATCH] Handle completely undecoded input in term (Bug#29918) * lisp/term.el (term-emulate-terminal): Avoid errors if the whole decoded string is eight-bit characters. Accumulate at most 4 undecoded bytes. --- lisp/term.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lisp/term.el b/lisp/term.el index cbef68dc0a..2fdd3253ec 100644 --- a/lisp/term.el +++ b/lisp/term.el @@ -2900,9 +2900,11 @@ term-emulate-terminal ;; next time. (when (= funny str-length) (let ((partial 0)) - (while (eq (char-charset (aref decoded-substring - (- count 1 partial))) - 'eight-bit) + (while (and (< partial count) + (< partial 4) + (eq (char-charset (aref decoded-substring + (- count 1 partial))) + 'eight-bit)) (cl-incf partial)) (when (> partial 0) (setq term-terminal-undecoded-bytes -- 2.11.0 --=-=-=--