aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-06-03 15:29:45 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-06-03 15:29:45 +0000
commitf1c8ccddde19739708d6d61a76381935eea4dd77 (patch)
treeeb92fc05b0e5174ac76088b294dfac7bc6e0f5e7
parentmeson/PKGBUILD: require fcft 2.1.1 (diff)
parentterm: set an initial TIOCSWINSZ right after opening the pty (diff)
Merge branch 'initial-tiocswinsz'
-rw-r--r--CHANGELOG.md2
-rw-r--r--terminal.c8
2 files changed, 10 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c5113e95..5aca097c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -48,6 +48,8 @@
* Selection of double-width characters. It is no longer possible to
select half of a double-width character.
* Draw hollow block cursor on top of character.
+* Set an initial `TIOCSWINSZ`. This ensures clients never reads a
+ `0x0` terminal size (https://codeberg.org/dnkl/foot/issues/20).
### Security
diff --git a/terminal.c b/terminal.c
index 4f9d1d5d..8181a610 100644
--- a/terminal.c
+++ b/terminal.c
@@ -8,6 +8,7 @@
#include <sys/stat.h>
#include <sys/wait.h>
+#include <sys/ioctl.h>
#include <sys/epoll.h>
#include <sys/eventfd.h>
#include <sys/timerfd.h>
@@ -759,6 +760,13 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
goto close_fds;
}
+ if (ioctl(ptmx, TIOCSWINSZ,
+ &(struct winsize){.ws_row = 24, .ws_col = 80}) < 0)
+ {
+ LOG_ERRNO("failed to set initial TIOCSWINSZ");
+ goto close_fds;
+ }
+
int ptmx_flags;
if ((ptmx_flags = fcntl(ptmx, F_GETFL)) < 0 ||
fcntl(ptmx, F_SETFL, ptmx_flags | O_NONBLOCK) < 0)