3 Commits

Author SHA1 Message Date
Avro
04ce0d643e fix async-unsafe error paths in sigchld()
die() calls vfprintf(3) and exit(3), which are not
async-signal-safe.  If SIGCHLD is handled while exiting, this
can make st hang or crash.

Commit d6ea0a1 replaced exit(3) by _exit(2) in sigchld()
but the error paths still call die().  Fix that by using
_exit(2) there as well.
2026-07-02 20:20:35 +02:00
Milos Nikic
688f70add0 st: guard tsetdirt() against zero-sized terminal
tsetdirt() assumes term.row > 0. During early init or
resize paths this may not hold, leading to out-of-bounds
access. Bail out early if there are no rows.
2026-01-16 14:12:07 +01:00
Roberto E. Vargas Caballero
0723b7e39e Disable bracked paste in reset
Sadly, there are too many programs today that enable this mode
and it is becoming very common to find the terminal adding
characters before and after in every of your pastes. A reset
should disable this mode.
2025-12-02 20:09:47 +01:00

25
st.c
View File

@@ -712,19 +712,24 @@ execsh(char *cmd, char **args)
void
sigchld(int a)
{
int stat;
int stat, olderrno;
pid_t p;
if ((p = waitpid(pid, &stat, WNOHANG)) < 0)
die("waiting for pid %hd failed: %s\n", pid, strerror(errno));
olderrno = errno;
do {
p = waitpid(pid, &stat, WNOHANG);
} while (p < 0 && errno == EINTR);
if (pid != p)
if (p < 0)
_exit(1);
if (pid != p) {
errno = olderrno;
return;
}
if (WIFEXITED(stat) && WEXITSTATUS(stat))
die("child exited with status %d\n", WEXITSTATUS(stat));
else if (WIFSIGNALED(stat))
die("child terminated due to signal %d\n", WTERMSIG(stat));
if ((WIFEXITED(stat) && WEXITSTATUS(stat)) || WIFSIGNALED(stat))
_exit(1);
_exit(0);
}
@@ -965,6 +970,9 @@ tsetdirt(int top, int bot)
{
int i;
if (term.row <= 0)
return;
LIMIT(top, 0, term.row-1);
LIMIT(bot, 0, term.row-1);
@@ -2358,6 +2366,7 @@ eschandle(uchar ascii)
resettitle();
xloadcols();
xsetmode(0, MODE_HIDE);
xsetmode(0, MODE_BRCKTPASTE);
break;
case '=': /* DECPAM -- Application keypad */
xsetmode(1, MODE_APPKEYPAD);