From a119ac10cc0a98ac26cfbb2ab66b034299350bc1 Mon Sep 17 00:00:00 2001 From: Boris Faure Date: Sun, 5 Apr 2020 15:49:26 +0200 Subject: [PATCH] tycat/tyls: handle error on write()/scanf() --- src/bin/tycat.c | 6 +++++- src/bin/tyls.c | 10 +++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/bin/tycat.c b/src/bin/tycat.c index 1a618c0d..d9a10efb 100644 --- a/src/bin/tycat.c +++ b/src/bin/tycat.c @@ -337,7 +337,11 @@ main(int argc, char **argv) echo_off(); snprintf(buf, sizeof(buf), "%c}qs", 0x1b); if (ty_write(1, buf, strlen(buf) + 1) < 0) - perror("write"); + { + perror("write"); + echo_on(); + goto shutdown; + } if (scanf("%i;%i;%i;%i", &tw, &th, &cw, &ch) != 4 || ((tw <= 0) || (th <= 0) || (cw <= 1) || (ch <= 1))) { diff --git a/src/bin/tyls.c b/src/bin/tyls.c index aa9a20d8..8c0c1904 100644 --- a/src/bin/tyls.c +++ b/src/bin/tyls.c @@ -760,18 +760,22 @@ main(int argc, char **argv) int i, cw, ch; int len; char *rp; - + evas = ecore_evas_get(ee); echo_off(); snprintf(buf, sizeof(buf), "%c}qs", 0x1b); len = strlen(buf); if (ty_write(1, buf, len + 1) < (signed)len + 1) - perror("write"); + { + perror("write"); + echo_on(); + return -1; + } if ((scanf("%i;%i;%i;%i", &tw, &th, &cw, &ch) != 4) || (tw <= 0) || (th <= 0) || (cw <= 1) || (ch <= 1)) { echo_on(); - return 0; + return -1; } echo_on(); for (i = 1; i < argc; i++)