Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp9499648imu; Wed, 5 Dec 2018 05:54:21 -0800 (PST) X-Google-Smtp-Source: AFSGD/UfHXdj3GkOpeqAIWdeESOW58c/Pe0SQnf1HEcIaob9txNStydt8UFVKhafM18+NkuAbiU6 X-Received: by 2002:a17:902:8607:: with SMTP id f7mr23681174plo.123.1544018061140; Wed, 05 Dec 2018 05:54:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544018061; cv=none; d=google.com; s=arc-20160816; b=YtsIy3XKtCzVlMlH1/UXRu1NMFgStdg03zLVYjdFUDOe4CyUmVyFmoqY0XkbFr7tRk ZFOD86Ho8/Fkn+Zt8FhN3TiQgSOuPOx1xRVCrJ9UeemCpPqY+S0Ww5dcD1SlV1fMuDSj mRFgaRfGLtlipboLqPMXuetzsffiCXo7iV8bHkM2Fc8xxTVgSvd4ITFXLtwvWgCSUp5Z 8laKbrEQfJVuo5aRq/G8Pm+ZtHCqcqgHj8cXaUzvjJnhUqphjuqHs12tpG2KD3bgaBa6 v/OXmYWr72tqxXnYah8/brGyk05agLFH5FQ9krhLXUpgXX+p8A9EfiQAXoAXBXXyPug0 zaVw== 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 :message-id:date:subject:cc:to:from; bh=fkPG0glpicXQJiVbZN8VdtkKLEM77PQbprTtAH8yN7o=; b=drE/bN+o+5YPCC5XWyMSRcHqDGXDQvpBlk4pSnO6PBhgUdNe5gqgq6lo9+KO/1shF7 ij+Q2kJSUaxcHTzo7LVi1mlN5ci55iEsncxevy+1qk4ya+KhB96HYaMYRcDgUTo4YRRi djwHh9Hbf/Lhge7JdEEm42V39U2+QsjoRg+w8HP7rGoBb0B5rEzgpifeW6QxPhQ+e1+N JyNpMmuYsYwTmhkP8w7+eVnEiUHwx0HHOLorczN4XUdWFui1RykZgMh9q8k/Nu+Pv/kT KQz6XGxu8J/FA7SYgZ7S14SJDVDc/2zgtVOHgfr6x/7/xlzBpfB4WdGQVk53iht0OUpX pvzg== 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 m15si18158437pgc.381.2018.12.05.05.54.06; Wed, 05 Dec 2018 05:54:21 -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 S1727549AbeLENxJ (ORCPT + 99 others); Wed, 5 Dec 2018 08:53:09 -0500 Received: from unicorn.mansr.com ([81.2.72.234]:54966 "EHLO unicorn.mansr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727491AbeLENxJ (ORCPT ); Wed, 5 Dec 2018 08:53:09 -0500 Received: by unicorn.mansr.com (Postfix, from userid 51770) id CE282149B5; Wed, 5 Dec 2018 13:53:06 +0000 (GMT) From: Mans Rullgard To: Miguel Ojeda Sandonis Cc: linux-kernel@vger.kernel.org Subject: [PATCH] auxdisplay: charlcd: fix x/y command parsing Date: Wed, 5 Dec 2018 13:52:47 +0000 Message-Id: <20181205135247.7964-1-mans@mansr.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. This reinstates the check for a final semicolon. Whereas the original code use strchr(), this is wasteful seeing as the semicolon is always at the end of the buffer. Thus check this character directly instead. Signed-off-by: Mans Rullgard --- drivers/auxdisplay/charlcd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/auxdisplay/charlcd.c b/drivers/auxdisplay/charlcd.c index 81c22d20d9d9..60e0b772673f 100644 --- a/drivers/auxdisplay/charlcd.c +++ b/drivers/auxdisplay/charlcd.c @@ -538,6 +538,9 @@ static inline int handle_lcd_special_code(struct charlcd *lcd) } case 'x': /* gotoxy : LxXXX[yYYY]; */ case 'y': /* gotoxy : LyYYY[xXXX]; */ + if (priv->esc_seq.buf[priv->esc_seq.len - 1] != ';') + break; + /* If the command is valid, move to the new address */ if (parse_xy(esc, &priv->addr.x, &priv->addr.y)) charlcd_gotoxy(lcd); -- 2.19.2