[PATCH weston] terminal: Don't crash when selecting non-ascii characters

Pekka Paalanen ppaalanen at gmail.com
Thu Sep 10 00:09:05 PDT 2015


On Wed, 9 Sep 2015 16:40:18 -0700
Bryce Harrington <bryce at osg.samsung.com> wrote:

> On Wed, Sep 02, 2015 at 04:21:54PM -0500, Derek Foreman wrote:
> > So it turns out if you cat /dev/urandom and drag select in the mess
> > you can crash weston-terminal.  There may also be more legitimate
> > ways of doing this.
> > 
> > The reason is that isalpha() and isdigit() only accept values that
> > fit within an unsigned char or are EOF.
> > 
> > By treating values < 0 the same as values > 127 we prevent this crash.
> > 
> > Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
> Reviewed-by: Bryce Harrington <bryce at osg.samsung.com>
> 
> > ---
> >  clients/terminal.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/clients/terminal.c b/clients/terminal.c
> > index f1d8fc0..c5d5d60 100644
> > --- a/clients/terminal.c
> > +++ b/clients/terminal.c
> > @@ -2579,7 +2579,7 @@ static int wordsep(int ch)
> >  {
> >  	const char extra[] = "-,./?%&#:_=+@~";
> >  
> > -	if (ch > 127)
> > +	if (ch > 127 || ch < 0)
> >  		return 1;
> >  
> >  	return ch == 0 || !(isalpha(ch) || isdigit(ch) || strchr(extra, ch));
> > -- 
> > 2.5.1

Nice, pushed:
   6179338..7978bc8  master -> master


Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 811 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20150910/e8212f3f/attachment.sig>


More information about the wayland-devel mailing list