[hackers] [scroll] fix compare bug for scroll events || Jan Klemkow

From: <git_AT_suckless.org>
Date: Sat, 4 Apr 2020 23:35:00 +0200 (CEST)

commit 5cfe13ab217d60cbfcdb6d7f5e60f5c290e5e3d1
Author: Jan Klemkow <j.klemkow_AT_wemelug.de>
AuthorDate: Sat Apr 4 22:45:58 2020 +0200
Commit: Jan Klemkow <j.klemkow_AT_wemelug.de>
CommitDate: Sat Apr 4 22:49:00 2020 +0200

    fix compare bug for scroll events

diff --git a/scroll.c b/scroll.c
index 4cb6102..f392fb9 100644
--- a/scroll.c
+++ b/scroll.c
_AT_@ -385,18 +385,19 @@ main(int argc, char *argv[])
                         die("poll:");
 
                 if (pfd[0].revents & POLLIN) {
- ssize_t n = read(STDIN_FILENO, input, sizeof input);
+ ssize_t n = read(STDIN_FILENO, input, sizeof(input)-1);
 
                         if (n <= 0 && errno != EINTR)
                                 die("read:");
 
- if (!altscreen && strncmp(KB_SCROLL_UP, input, n) == 0)
+ input[n] = '\0';
+ if (!altscreen && strcmp(KB_SCROLL_UP, input) == 0)
                                 scrollup(ws.ws_row);
- else if (!altscreen && strncmp(MS_SCROLL_UP, input, n) == 0)
+ else if (!altscreen && strcmp(MS_SCROLL_UP, input) == 0)
                                 scrollup(1);
- else if (!altscreen && strncmp(KB_SCROLL_DOWN, input, n) == 0)
+ else if (!altscreen && strcmp(KB_SCROLL_DOWN, input) == 0)
                                 scrolldown(buf, pos, ws.ws_row);
- else if (!altscreen && strncmp(MS_SCROLL_DOWN, input, n) == 0)
+ else if (!altscreen && strcmp(MS_SCROLL_DOWN, input) == 0)
                                 scrolldown(buf, pos, 1);
                         else if (write(mfd, input, n) == -1)
                                 die("write:");
Received on Sat Apr 04 2020 - 23:35:00 CEST

This archive was generated by hypermail 2.3.0 : Sat Apr 04 2020 - 23:36:36 CEST