From 958112c5a396815da7a731f406dbfd27bf713572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Tue, 5 Jan 2021 14:45:12 +0100 Subject: Refactor setting filter and use safe strncpy --- htop.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'htop.c') diff --git a/htop.c b/htop.c index 00ff1dab..a8935f40 100644 --- a/htop.c +++ b/htop.c @@ -248,13 +248,8 @@ static void setCommFilter(State* state, char** commFilter) { MainPanel* panel = (MainPanel*)state->panel; ProcessList* pl = state->pl; IncSet* inc = panel->inc; - size_t maxlen = sizeof(inc->modes[INC_FILTER].buffer) - 1; - char* buffer = inc->modes[INC_FILTER].buffer; - strncpy(buffer, *commFilter, maxlen); - buffer[maxlen] = 0; - inc->modes[INC_FILTER].index = strlen(buffer); - inc->filtering = true; + IncSet_setFilter(inc, *commFilter); pl->incFilter = IncSet_filter(inc); free(*commFilter); -- cgit v1.2.3