Introduction
Introduction Statistics Contact Development Disclaimer Help
fix strncmp bug by using strcmp - scroll - scrollbackbuffer program for st
git clone git://git.suckless.org/scroll
Log
Files
Refs
README
LICENSE
---
commit 91d126eabe33630163d15f9bb423ca95f95333f4
parent 6e7406cde8b517ecee582856ffbaaaea63e98661
Author: Jan Klemkow <[email protected]>
Date: Tue, 14 Apr 2020 22:40:50 +0200
fix strncmp bug by using strcmp
if input is just a single ESC character, strncmp
just compares the first char of the constant string.
Diffstat:
M scroll.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/scroll.c b/scroll.c
@@ -506,18 +506,20 @@ main(int argc, char *argv[])
}
out:
if (pfd[1].revents & POLLIN) {
- ssize_t n = read(mfd, input, sizeof input);
+ ssize_t n = read(mfd, input, sizeof(input)-1);
if (n == -1 && errno != EINTR)
die("read:");
if (n == 0) /* on exit of child we continue her…
continue; /* let signal handler catch SIGCHLD …
+ input[n] = '\0';
+
if (write(STDOUT_FILENO, input, n) == -1)
die("write:");
/* don't save clear screen esc sequences in log */
- if (strncmp("\033[H\033[2J", input, n) == 0)
+ if (strcmp("\033[H\033[2J", input) == 0)
continue;
/* iterate over the input buffer */
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.