ref: 1442891a3e9f3047b0fda4fed8afc0de5fc7da1a
parent: 51c899ca0154d43a42dca91d2cf0e03fc429ce58
author: rodri <rgl@antares-labs.eu>
date: Tue Jul 16 07:29:49 EDT 2024
samterm: avoid division-by-zero when $tabstop is zero or empty this happens in libframe: /sys/src/libframe/frutil.c:80: x -= (x-f->r.min.x)%f->maxtab; but there's no way to control when the user changes the maxtab value, so it's samterm's responsibility to sanitize it.
--- a/sys/src/cmd/samterm/plan9.c
+++ b/sys/src/cmd/samterm/plan9.c
@@ -26,6 +26,7 @@
getscreen(int argc, char **argv)
{
char *t;
+ uint tlen;
ARGBEGIN{
case 'a':
@@ -43,8 +44,8 @@
threadexitsall("init");
}
t = getenv("tabstop");
- if(t != nil)
- maxtab = strtoul(t, nil, 0);
+ if(t != nil && (tlen = strtoul(t, nil, 0)) > 0)
+ maxtab = tlen;
free(t);
draw(screen, screen->clipr, display->white, nil, ZP);
}
--
⑨