Introduction
Introduction Statistics Contact Development Disclaimer Help
Error handling for getcursorposition - scroll - scrollbackbuffer program for st
git clone git://git.suckless.org/scroll
Log
Files
Refs
README
LICENSE
---
commit 6f1e4abb64c2d4204c722d5357da004062f90b92
parent 177976ae00fc60658c6f21739a3fd2462a02917f
Author: Jochen Sprickerhof <[email protected]>
Date: Wed, 15 Apr 2020 23:08:35 +0200
Error handling for getcursorposition
Diffstat:
M scroll.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/scroll.c b/scroll.c
@@ -254,10 +254,17 @@ void
getcursorposition(int *x, int *y)
{
char input[BUFSIZ];
- write(STDOUT_FILENO, "\033[6n", 4);
- ssize_t n = read(STDIN_FILENO, input, sizeof(input)-1);
+ ssize_t n;
+
+ if (write(STDOUT_FILENO, "\033[6n", 4) < 0)
+ die("requesting cursor position");
+
+ if ((n = read(STDIN_FILENO, input, sizeof(input)-1)) < 0)
+ die("reading cursor position");
input[n] = '\0';
- sscanf(input, "\033[%d;%dR", x, y);
+
+ if (sscanf(input, "\033[%d;%dR", x, y) != 2)
+ die("parsing cursor position");
}
void
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.