From 1e0c530a465662c4049a6ea93ecda6b006ba45bd Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Sat, 21 Mar 2015 16:52:54 -0300 Subject: [PATCH 1/2] Tempus fugit. --- Action.c | 2 +- Action.h | 2 +- Process.c | 2 +- Process.h | 2 +- htop.1.in | 2 +- htop.c | 2 +- htop.h | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Action.c b/Action.c index 499422e0..d070501e 100644 --- a/Action.c +++ b/Action.c @@ -1,6 +1,6 @@ /* htop - Action.c -(C) 2014 Hisham H. Muhammad +(C) 2015 Hisham H. Muhammad Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ diff --git a/Action.h b/Action.h index 7571ba41..13f10274 100644 --- a/Action.h +++ b/Action.h @@ -4,7 +4,7 @@ #define HEADER_Action /* htop - Action.h -(C) 2014 Hisham H. Muhammad +(C) 2015 Hisham H. Muhammad Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ diff --git a/Process.c b/Process.c index 16ac7001..ff1baba2 100644 --- a/Process.c +++ b/Process.c @@ -1,6 +1,6 @@ /* htop - Process.c -(C) 2004-2014 Hisham H. Muhammad +(C) 2004-2015 Hisham H. Muhammad Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ diff --git a/Process.h b/Process.h index 5affabee..be54adab 100644 --- a/Process.h +++ b/Process.h @@ -4,7 +4,7 @@ #define HEADER_Process /* htop - Process.h -(C) 2004-2014 Hisham H. Muhammad +(C) 2004-2015 Hisham H. Muhammad Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ diff --git a/htop.1.in b/htop.1.in index c4621ab3..f55e6420 100644 --- a/htop.1.in +++ b/htop.1.in @@ -1,4 +1,4 @@ -.TH "HTOP" "1" "2014" "@PACKAGE_STRING@" "Utils" +.TH "HTOP" "1" "2015" "@PACKAGE_STRING@" "Utils" .SH "NAME" htop \- interactive process viewer .SH "SYNOPSIS" diff --git a/htop.c b/htop.c index 66088e7a..281d40ea 100644 --- a/htop.c +++ b/htop.c @@ -42,7 +42,7 @@ in the source distribution for its full text. //#link m -#define COPYRIGHT "(C) 2004-2014 Hisham Muhammad" +#define COPYRIGHT "(C) 2004-2015 Hisham Muhammad" static void printVersionFlag() { fputs("htop " VERSION " - " COPYRIGHT "\n" diff --git a/htop.h b/htop.h index 77f6e2e8..db03da9e 100644 --- a/htop.h +++ b/htop.h @@ -11,7 +11,7 @@ in the source distribution for its full text. //#link m -#define COPYRIGHT "(C) 2004-2014 Hisham Muhammad" +#define COPYRIGHT "(C) 2004-2015 Hisham Muhammad" // ---------------------------------------- From 442a0d33e43b93e675281de70d6eacf9a9d4b8f8 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Sun, 22 Mar 2015 22:56:28 -0300 Subject: [PATCH 2/2] Do not trust isalpha(c) for values > 255. Fixes #174. --- AvailableColumnsPanel.c | 2 +- CategoriesPanel.c | 2 +- ColumnsPanel.c | 2 +- IncSet.c | 2 +- Panel.c | 2 +- RichString.c | 2 +- htop.c | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/AvailableColumnsPanel.c b/AvailableColumnsPanel.c index d954da8c..6c4b5ef5 100644 --- a/AvailableColumnsPanel.c +++ b/AvailableColumnsPanel.c @@ -55,7 +55,7 @@ static HandlerResult AvailableColumnsPanel_eventHandler(Panel* super, int ch) { } default: { - if (isalpha(ch)) + if (ch < 255 && isalpha(ch)) result = Panel_selectByTyping(super, ch); break; } diff --git a/CategoriesPanel.c b/CategoriesPanel.c index bf6ee543..084f48e4 100644 --- a/CategoriesPanel.c +++ b/CategoriesPanel.c @@ -102,7 +102,7 @@ static HandlerResult CategoriesPanel_eventHandler(Panel* super, int ch) { break; } default: - if (isalpha(ch)) + if (ch < 255 && isalpha(ch)) result = Panel_selectByTyping(super, ch); if (result == BREAK_LOOP) result = IGNORED; diff --git a/ColumnsPanel.c b/ColumnsPanel.c index f4eed99e..844e9580 100644 --- a/ColumnsPanel.c +++ b/ColumnsPanel.c @@ -70,7 +70,7 @@ static HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch) { } default: { - if (isalpha(ch)) + if (ch < 255 && isalpha(ch)) result = Panel_selectByTyping(super, ch); if (result == BREAK_LOOP) result = IGNORED; diff --git a/IncSet.c b/IncSet.c index 40aa9233..a7761602 100644 --- a/IncSet.c +++ b/IncSet.c @@ -153,7 +153,7 @@ bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue } } doSearch = false; - } else if (isprint((char)ch) && (mode->index < INCMODE_MAX)) { + } else if (ch < 255 && isprint((char)ch) && (mode->index < INCMODE_MAX)) { mode->buffer[mode->index] = ch; mode->index++; mode->buffer[mode->index] = 0; diff --git a/Panel.c b/Panel.c index 4355b1e2..681e9ca5 100644 --- a/Panel.c +++ b/Panel.c @@ -427,7 +427,7 @@ HandlerResult Panel_selectByTyping(Panel* this, int ch) { if (!this->eventHandlerBuffer) this->eventHandlerBuffer = calloc(100, 1); - if (isalnum(ch)) { + if (ch < 255 && isalnum(ch)) { int len = strlen(this->eventHandlerBuffer); if (len < 99) { this->eventHandlerBuffer[len] = ch; diff --git a/RichString.c b/RichString.c index 51914b08..22ffecb5 100644 --- a/RichString.c +++ b/RichString.c @@ -128,7 +128,7 @@ static inline void RichString_writeFrom(RichString* this, int attrs, const char* int newLen = from + len; RichString_setLen(this, newLen); for (int i = from, j = 0; i < newLen; i++, j++) - this->chptr[i] = (isprint(data_c[j]) ? data_c[j] : '?') | attrs; + this->chptr[i] = (data_c[j] >= 32 ? data_c[j] : '?') | attrs; this->chptr[newLen] = 0; } diff --git a/htop.c b/htop.c index 281d40ea..62e49c9c 100644 --- a/htop.c +++ b/htop.c @@ -852,7 +852,7 @@ int main(int argc, char** argv) { continue; } - if (isdigit((char)ch)) { + if (ch < 255 && isdigit((char)ch)) { if (Panel_size(panel) == 0) continue; pid_t pid = ch-48 + acc; for (int i = 0; i < ProcessList_size(pl); i++) {