diff options
author | Derek Foreman <derekf@osg.samsung.com> | 2015-09-02 16:21:54 -0500 |
---|---|---|
committer | Pekka Paalanen <pekka.paalanen@collabora.co.uk> | 2015-09-10 10:07:16 +0300 |
commit | 7978bc82dd056933a3998c54d9a7bd43cecae19f (patch) | |
tree | 159bcbc966afce4597ac3826ec97da70f3dc3358 | |
parent | 617933840bd3c190d0bd3c4aa4acf99d3caea016 (diff) | |
download | weston-7978bc82dd056933a3998c54d9a7bd43cecae19f.tar.gz |
terminal: Don't crash when selecting non-ascii characters
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@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
-rw-r--r-- | clients/terminal.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/clients/terminal.c b/clients/terminal.c index f1d8fc04..c5d5d608 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)); |