6 Commits
Author SHA1 Message Date
Hiltjo Posthuma fdaadd5b1e config.def.h: add a comment to prevent a user config error
tabspaces must be > 0 or else it will loop forever
2026-10-16 13:14:55 +02:00
Hiltjo Posthuma 2f02c153d5 add some range checks for ATTR_WIDE and ATTR_WDUMMY
The handling for ATTR_WIDE and ATTR_WDUMMY might be incomplete and need more
work. This is a quick fix to at least not allow out of bounds writes.

To reproduce:

	printf '\u4e00\r\033[PA'

Reported by: jb19357 <jb19357@protonmail.com>

Thanks!
2026-10-16 13:10:59 +02:00
Hiltjo Posthuma 3caed3e78f check XGetWMHints() return value 2026-10-16 13:08:47 +02:00
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
3 changed files with 26 additions and 12 deletions

No files matched your search

+1 -1
View File
@@ -91,7 +91,7 @@ char *termname = "st-256color";
* *
* stty tabs * stty tabs
*/ */
unsigned int tabspaces = 8; unsigned int tabspaces = 8; /* must be > 0 */
/* Terminal colors (16 first used in escape sequence) */ /* Terminal colors (16 first used in escape sequence) */
static const char *colorname[] = { static const char *colorname[] = {
+21 -10
View File
@@ -712,19 +712,24 @@ execsh(char *cmd, char **args)
void void
sigchld(int a) sigchld(int a)
{ {
int stat; int stat, olderrno;
pid_t p; pid_t p;
if ((p = waitpid(pid, &stat, WNOHANG)) < 0) olderrno = errno;
die("waiting for pid %hd failed: %s\n", pid, strerror(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; return;
}
if (WIFEXITED(stat) && WEXITSTATUS(stat)) if ((WIFEXITED(stat) && WEXITSTATUS(stat)) || WIFSIGNALED(stat))
die("child exited with status %d\n", WEXITSTATUS(stat)); _exit(1);
else if (WIFSIGNALED(stat))
die("child terminated due to signal %d\n", WTERMSIG(stat));
_exit(0); _exit(0);
} }
@@ -965,6 +970,9 @@ tsetdirt(int top, int bot)
{ {
int i; int i;
if (term.row <= 0)
return;
LIMIT(top, 0, term.row-1); LIMIT(top, 0, term.row-1);
LIMIT(bot, 0, term.row-1); LIMIT(bot, 0, term.row-1);
@@ -1211,9 +1219,11 @@ tsetchar(Rune u, const Glyph *attr, int x, int y)
term.line[y][x+1].mode &= ~ATTR_WDUMMY; term.line[y][x+1].mode &= ~ATTR_WDUMMY;
} }
} else if (term.line[y][x].mode & ATTR_WDUMMY) { } else if (term.line[y][x].mode & ATTR_WDUMMY) {
if (x > 0) {
term.line[y][x-1].u = ' '; term.line[y][x-1].u = ' ';
term.line[y][x-1].mode &= ~ATTR_WIDE; term.line[y][x-1].mode &= ~ATTR_WIDE;
} }
}
term.dirty[y] = 1; term.dirty[y] = 1;
term.line[y][x] = *attr; term.line[y][x] = *attr;
@@ -2358,6 +2368,7 @@ eschandle(uchar ascii)
resettitle(); resettitle();
xloadcols(); xloadcols();
xsetmode(0, MODE_HIDE); xsetmode(0, MODE_HIDE);
xsetmode(0, MODE_BRCKTPASTE);
break; break;
case '=': /* DECPAM -- Application keypad */ case '=': /* DECPAM -- Application keypad */
xsetmode(1, MODE_APPKEYPAD); xsetmode(1, MODE_APPKEYPAD);
@@ -2678,9 +2689,9 @@ draw(void)
/* adjust cursor position */ /* adjust cursor position */
LIMIT(term.ocx, 0, term.col-1); LIMIT(term.ocx, 0, term.col-1);
LIMIT(term.ocy, 0, term.row-1); LIMIT(term.ocy, 0, term.row-1);
if (term.line[term.ocy][term.ocx].mode & ATTR_WDUMMY) if (term.ocx > 0 && (term.line[term.ocy][term.ocx].mode & ATTR_WDUMMY))
term.ocx--; term.ocx--;
if (term.line[term.c.y][cx].mode & ATTR_WDUMMY) if (cx > 0 && (term.line[term.c.y][cx].mode & ATTR_WDUMMY))
cx--; cx--;
drawregion(0, 0, term.col, term.row); drawregion(0, 0, term.col, term.row);
+4 -1
View File
@@ -1755,7 +1755,10 @@ xsetcursor(int cursor)
void void
xseturgency(int add) xseturgency(int add)
{ {
XWMHints *h = XGetWMHints(xw.dpy, xw.win); XWMHints *h;
if (!(h = XGetWMHints(xw.dpy, xw.win)))
return;
MODBIT(h->flags, add, XUrgencyHint); MODBIT(h->flags, add, XUrgencyHint);
XSetWMHints(xw.dpy, xw.win, h); XSetWMHints(xw.dpy, xw.win, h);