Received: by 10.223.185.116 with SMTP id b49csp3504287wrg; Mon, 26 Feb 2018 00:47:03 -0800 (PST) X-Google-Smtp-Source: AH8x227U0/+VZyt0wsaGWxc3oclFiq5UurtyrpR5gO/FnL1IhZUugd+N1acOCDMoFhyLjKYJ1TRK X-Received: by 2002:a17:902:5716:: with SMTP id k22-v6mr10101900pli.229.1519634823677; Mon, 26 Feb 2018 00:47:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519634823; cv=none; d=google.com; s=arc-20160816; b=CmJAYIdDPg78KzN2TmjRZ0zS5gXwoxGk5jJ0zVVDcNXSAsv5yPiTzD6vekcD/OlkA2 wODddwoMNZu/EyYw6xW5LAsPt3bl5OPEpj9xdymixZFHXsNP8CptLL9yvj+Re+K4eNgH WGIuEi2KLtpUdF/RnXqnSB2JrUGBMidktoZmeJnrShcJgtSXRA6rFR2TwKrl7xaaOEBs LvEBIJFp2o4Yck40xp+I/nPFOQ0OHp3BkBdvp6uBWzbtN3eEkRE3/b/8E2bIbCYZkhE8 zrfztlx4U40KjiHhGzmRU/iit0/n3iyks22mwc8Isfdbh349UuDkKugOdvf81dqQgY6I +D7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=TNFujrEZuIC81SlsN/W3PBev7kjaJP/3X1mq4l32VTY=; b=WIY/2mHyEvZmcSS3XDa7O6Tw+XouFv2hI6QzNbsVbQ/dwvgn3mSWT4HUvKLt6kFAGV AiFwKAXdYQUkIkvquJIRiVMsVO+vWZ3+sW1xxZyEpJ8MWqL+jLpKvoPPFq/YE0WavRyi d9Fv72OBy+lPzxOjRSocoz0Z7vKWeKy7IEeIuzFXVqRXYbpZAfb8z2InHW0aSLpYDBIk TIWoKD1dbzQ9hvbfYDZIncAGwJvx0eXmen1V1aCL90D0xyxfIJhRGSHKvz7EvikF2Zfo WcIaluzpcZgbHovDaiIwd+b1sehjLZdOfSm/mH9W6uArWjQLQf/1nFDrHjcAGb/zBYLC yZYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=k1nc7qR7; 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 j10si1252498pgq.431.2018.02.26.00.46.48; Mon, 26 Feb 2018 00:47:03 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=k1nc7qR7; 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 S1751879AbeBZIqL (ORCPT + 99 others); Mon, 26 Feb 2018 03:46:11 -0500 Received: from mail-qt0-f196.google.com ([209.85.216.196]:33894 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751022AbeBZIqK (ORCPT ); Mon, 26 Feb 2018 03:46:10 -0500 Received: by mail-qt0-f196.google.com with SMTP id l25so8016093qtj.1 for ; Mon, 26 Feb 2018 00:46:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=TNFujrEZuIC81SlsN/W3PBev7kjaJP/3X1mq4l32VTY=; b=k1nc7qR7TwcumTXlqTX1l0FTPAWR+X6r0w0UcG8H/KipVwmlDqzlU3xTbYesocy9X+ UxqSJCgK+tUvWzJS7jm2Kvz8OO5fAEkVh2dWuDwYcE4OV3n0li5J2zt7AAX0+hrj7FuT vYdi5g8T4PcWtmT/vq0QVHS+ip1iGKNu86k2/L55NWUR4tFwMObUfxpasA90BT3rFQra XI9CAxrtm1/7K64uI0HLk1WIV6OUCvpPlYYFTknqxZ8b5fhHjqxDiUsS2McCPeSHgV7L Wsj4fPFHly7cht9CaFiFIOGkBrNndaHrEwQnLI+4vb7v5F+5CamT8X1tvQcm9P4ZmZHM FeHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=TNFujrEZuIC81SlsN/W3PBev7kjaJP/3X1mq4l32VTY=; b=g4G9deymZqaWn0lYtRkAD5NYJiHQhVrR0KrjaM5zTkEyoi4wFKxiJlpPUbCosrk8MU KeDw+K3QnPtn12lWf1RpLMm4pTsx3X/8P0G3ozXFOWqWGjnybSpLAtdAit1g0s3Pcq4N 8Qn3VkmdATgB7arwvDhUDl42tjLqyhksTUTloj3phrvp3QjkU24WE6KqKbMjGtyZCl/Z Y5C4IcVL+Ah98mM9A19CMWrBRQ1ny0MeTOz95acWiP+wo0GFnyfhb70gD6II8sTzeVe4 8xlUwbBuVqa4FQUyPjbYFMAlyMpAtHaVVcKq20tzvwTuPsHdGGT3G2NfiYehEnPgtatr 5XrQ== X-Gm-Message-State: APf1xPCz/wzynniOkHD7RrD4zB0kGbnPzl+GXivq2veb0SVVSarDxjk4 ZEnJGU34RkUCrQoq6/RkYTBYWpj02T5zXxC43zsikg== X-Received: by 10.237.36.110 with SMTP id s43mr16499253qtc.23.1519634769189; Mon, 26 Feb 2018 00:46:09 -0800 (PST) MIME-Version: 1.0 Received: by 10.200.47.219 with HTTP; Mon, 26 Feb 2018 00:46:08 -0800 (PST) In-Reply-To: <20180225235432.31209-4-rabel@robertabel.eu> References: <9ec3c54c-f8fe-22d7-783e-8cf9862405bb@robertabel.eu> <20180225235432.31209-1-rabel@robertabel.eu> <20180225235432.31209-2-rabel@robertabel.eu> <20180225235432.31209-3-rabel@robertabel.eu> <20180225235432.31209-4-rabel@robertabel.eu> From: Geert Uytterhoeven Date: Mon, 26 Feb 2018 09:46:08 +0100 X-Google-Sender-Auth: -5YqLas176jUPT0dOcOi0SVY1N4 Message-ID: Subject: Re: [PATCH 3/4] auxdisplay: charlcd: fix x/y address commands To: Robert Abel Cc: linux-kernel , Miguel Ojeda , Willy Tarreau , Andy Shevchenko Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Robert, On Mon, Feb 26, 2018 at 12:54 AM, Robert Abel wrote: > NUL-terminate each individual number to be parsed. > To do this, the next command character and a pointer to its argument > are found and stored. The command character is then overwritten by NUL > before kstr* functions are called on the buffer. > > Signed-off-by: Robert Abel Thanks for your patch! > --- a/drivers/auxdisplay/charlcd.c > +++ b/drivers/auxdisplay/charlcd.c > @@ -471,28 +471,63 @@ static inline int handle_lcd_special_code(struct charlcd *lcd) > break; > } > case 'x': /* gotoxy : LxXXX[yYYY]; */ > - case 'y': /* gotoxy : LyYYY[xXXX]; */ > + case 'y': { /* gotoxy : LyYYY[xXXX]; */ > + > + char* nxt_esc; > + char nxt_cmd; > + char cmd; > + struct charlcd_priv_addr tmp_addr; > + > if (!strchr(esc, ';')) > break; > > - while (*esc) { > - if (*esc == 'x') { > - esc++; > - if (kstrtoul(esc, 10, &priv->addr.x) < 0) > + /* sequence is processed whether legal or illegal */ > + processed = 1; > + > + /* copy current address to temporary buffer */ > + tmp_addr = priv->addr; > + > + nxt_cmd = *esc++; > + nxt_esc = esc; > + > + while ('\0' != *esc) { > + > + cmd = nxt_cmd; > + esc = nxt_esc; > + nxt_esc = strpbrk(esc, "xy;"); > + if (NULL != nxt_esc) { > + nxt_cmd = *nxt_esc; > + /* terminate current sequence with NUL */ > + *nxt_esc++ = '\0'; > + } So if none of "x", "y", or ";" is found, nxt_cmd will still contain the current command? Shouldn't it be reset to '\0' or so? > + > + if ('x' == cmd) { > + if (kstrtoul(esc, 10, &tmp_addr.x) < 0) > break; > - } else if (*esc == 'y') { > - esc++; > - if (kstrtoul(esc, 10, &priv->addr.y) < 0) > + } else if ('y' == cmd) { > + if (kstrtoul(esc, 10, &tmp_addr.y) < 0) > break; > } else { > + /* break on unknown command or ';' */ > break; > } > + > } > > + /* unknown commands in sequence will be followed by at least ';' */ > + if ('\0' != *esc) > + break; > + > + /* clamp new x/y coordinates */ > + if (tmp_addr.x >= lcd->width) > + tmp_addr.x = lcd->width - 1; > + tmp_addr.y %= lcd->height; > + > + priv->addr = tmp_addr; > charlcd_gotoxy(lcd); > - processed = 1; > break; > } > + } > > /* TODO: This indent party here got ugly, clean it! */ > /* Check whether one flag was changed */ Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds