Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp9772686imu; Wed, 5 Dec 2018 10:00:33 -0800 (PST) X-Google-Smtp-Source: AFSGD/UVd34XrVRmU9P23DLqAZFKcgWE6PTJ1f/d8D4CGLeyGZlSMXoejopfHogtpRw4dN+gJ7cS X-Received: by 2002:a17:902:7686:: with SMTP id m6mr25774194pll.179.1544032832980; Wed, 05 Dec 2018 10:00:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544032832; cv=none; d=google.com; s=arc-20160816; b=OJfpv579m883cKhSn60duOXogNSxdFcDGdDehKXDvTjOvPmx2fN9MBkpDQBDByIDb2 ik2aBkGwapdf1TzjPMZbOxVPBfSo618CnCvhcTKXm4b60KUIn6XVG255dF2wb7gB65Vw z8ow2lTASz3IxPm7QXO4jfNr8oZsGTfhL2ltfFuOsNbAf4zWd67Gg5APVsqBBdr6BTgr paReIV/amHG2LLSBGpB+lEW+GF8Hm1G8+EldORTl7SynnXEw5ftxXiRKaO1MinvL+XR7 cTfczSKwiDV4Za1TYw81rZInhKqAVDzQYKqe8tw0IooCDw0pfO2AKLrZKWyQt5GAWivP 1/nQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:message-id:in-reply-to:date:references:subject:cc:to :from; bh=2yw88yH8EjYpgatmRSj7QJZ1IdEdmoqC3HNZvaV1THg=; b=K/QxpwP5hYc8e+lPkDpn+bJCp1O4qZc90aYJYFRHO9IHNfuF58eOjBeRR4lAmnIimO TZ7cCcJymMF7GgSMAnY9ZFapfz1IgMJ2t+oU6zZ8KOi7XmsvgSxTQLVCvBAcdRVI5CEU xsyi8btRmrlRGQs5IdGiacr4ekULBC/MM9dHgBt0Z7FQZZ24Yr/OjuDV+oAYVbrcr879 E3zgYQK7t9vejYdZ0bG0aJxEAoeNAvJ9Gsl5mz3ol3IL4hyxdXxF5TJOOyvjwLeTriXA hpZOnB3p4fz4+z7KIkdcK3CZu2ZfGV9FqCmCGIZhrosZKvcwiQucjmSnM4ASb4qxoTa/ vUZg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w12si20846338pfn.212.2018.12.05.10.00.16; Wed, 05 Dec 2018 10:00:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727695AbeLER63 convert rfc822-to-8bit (ORCPT + 99 others); Wed, 5 Dec 2018 12:58:29 -0500 Received: from unicorn.mansr.com ([81.2.72.234]:56366 "EHLO unicorn.mansr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727257AbeLER63 (ORCPT ); Wed, 5 Dec 2018 12:58:29 -0500 Received: by unicorn.mansr.com (Postfix, from userid 51770) id CAE3A149B5; Wed, 5 Dec 2018 17:58:26 +0000 (GMT) From: =?iso-8859-1?Q?M=E5ns_Rullg=E5rd?= To: Miguel Ojeda Cc: linux-kernel , Robert Abel , Geert Uytterhoeven , Willy Tarreau , Andy Shevchenko Subject: Re: [PATCH] auxdisplay: charlcd: fix x/y command parsing References: <20181205135247.7964-1-mans@mansr.com> Date: Wed, 05 Dec 2018 17:58:26 +0000 In-Reply-To: (Miguel Ojeda's message of "Wed, 5 Dec 2018 17:47:31 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Miguel Ojeda writes: > Hi Mans, > > [CC'ing a few people involved previously on this] > > On Wed, Dec 5, 2018 at 2:53 PM Mans Rullgard wrote: >> >> Commit b34050fadb86 ("auxdisplay: charlcd: Fix and clean up handling of >> x/y commands") fixed some problems by rewriting the parsing code, >> but also broke things further by removing the check for a complete >> command before attempting to parse it. As a result, parsing is >> terminated at the first x or y character. > > Why is it necessary to check for ";" to be exactly at the end? Or, in > other words, what requires it? > > If the syntax supported by parse_xy() is wrong for some reason, we > should fix that (instead of adding a check before calling it). Suppose the command "\e[Lx0y0;" is written to the device. The charlcd_write_char() function adds one character at a time to the escape sequence buffer. Once the 'L' has been seen, it calls handle_lcd_special_code() after each additional character is added. On encountering the 'x' this function will attempt to parse the command using parse_xy(), which fails since it is incomplete. It is nonetheless reported as processed, and the escape sequence is flushed. The remainder of the command (i.e. "0y0;") is then displayed as text. Since parse_xy() can never return success (true) unless there is a semicolon, it is pointless to call it until we have seen one. With the characters being added to the buffer one by one, it is enough to check for semicolon at the end. BTW, the parsing of this command has been broken since 3.2-rc1 due to commit 129957069e6a. -- M?ns Rullg?rd