mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ian Abbott <abbotti@mev.co.uk>
To: Bastian Stender <bst@pengutronix.de>,
	Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v3] fbconsole: check cursor position before moving
Date: Mon, 27 Feb 2017 18:51:38 +0000	[thread overview]
Message-ID: <94b8168e-0fd1-eb88-06d0-434b7c1ab1c0@mev.co.uk> (raw)
In-Reply-To: <7649641e-ac3b-b184-582e-18400a1d6d45@mev.co.uk>

On 27/02/17 18:46, Ian Abbott wrote:
> On 27/02/17 13:39, Bastian Stender wrote:
>> Moving the cursor to x=2, y=2 with "\e[3;3H" on a 12x2 framebuffer
>> console lead to a barebox crash while drawing the cursor. If the
>> cursor position is out of bounds clip the cursor to the corresponding
>> edge.
>>
>> Signed-off-by: Bastian Stender <bst@pengutronix.de>
>> ---
>>  drivers/video/fbconsole.c | 7 +++++--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/video/fbconsole.c b/drivers/video/fbconsole.c
>> index 64f7d7364e..33649c597d 100644
>> --- a/drivers/video/fbconsole.c
>> +++ b/drivers/video/fbconsole.c
>> @@ -264,10 +264,13 @@ static void fbc_parse_csi(struct fbc_priv *priv)
>>          return;
>>      case 'H':
>>          video_invertchar(priv, priv->x, priv->y);
>> +
>>          pos = simple_strtoul(priv->csi, &end, 10);
>> -        priv->y = pos ? pos - 1 : 0;
>> +        priv->y = clamp(pos - 1, 0, (int) priv->rows);
>> +
>
> That allows priv->y to be set to priv->rows, which is one too many.

Ignore that.  My mistake.  It appears that priv->rows is the number of 
rows minus 1, so the above code is fine.  Same for priv->x.

-- 
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@mev.co.uk> )=-
-=(                          Web: http://www.mev.co.uk/  )=-

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2017-02-27 18:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-23 17:20 [PATCH 1/2] " Bastian Stender
2017-02-23 17:20 ` [PATCH 2/2] fbconsole: implement vt100 cursor shown/hidden Bastian Stender
2017-02-24  7:32 ` [PATCH 1/2] fbconsole: check cursor position before moving Sascha Hauer
2017-02-24 11:18   ` Ian Abbott
2017-02-24 13:22     ` Bastian Stender
2017-02-24 13:36       ` [PATCH v2] " Bastian Stender
2017-02-27  7:57         ` Sascha Hauer
2017-02-27 13:39           ` [PATCH v3] " Bastian Stender
2017-02-27 18:46             ` Ian Abbott
2017-02-27 18:51               ` Ian Abbott [this message]
2017-02-28  6:46             ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=94b8168e-0fd1-eb88-06d0-434b7c1ab1c0@mev.co.uk \
    --to=abbotti@mev.co.uk \
    --cc=barebox@lists.infradead.org \
    --cc=bst@pengutronix.de \
    --cc=s.hauer@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox