xtermset: fix two issues about dealing with configuration files

- Fix array bounds that caused a segfault while storing the config file
- Ensure that we hit EOF while storing/loading the config file on
unsigned char archs (powerpc, arm)

Wording hint and OK tb@
This commit is contained in:
cwen 2020-10-13 15:10:39 +00:00
parent 9c74f2bae2
commit 2e32c1056f
3 changed files with 39 additions and 3 deletions

View File

@ -1,15 +1,15 @@
# $OpenBSD: Makefile,v 1.19 2019/07/12 21:02:30 sthen Exp $
# $OpenBSD: Makefile,v 1.20 2020/10/13 15:10:39 cwen Exp $
COMMENT= dynamically change some settings of an xterm
DISTNAME= xtermset-0.5.2
REVISION= 2
REVISION= 3
CATEGORIES= x11
# GPL
PERMIT_PACKAGE= Yes
WANTLIB= c
WANTLIB= c
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=clts/}

View File

@ -0,0 +1,17 @@
$OpenBSD: patch-src_term_c,v 1.1 2020/10/13 15:10:39 cwen Exp $
Be sure we hit EOF while loading the configuration file on archs where char is
unsigned (ppc, arm)
Index: src/term.c
--- src/term.c.orig
+++ src/term.c
@@ -116,7 +116,7 @@ void term_loadall() {
good_term *n;
char line[MAXTERMCHARS+3];
int i,j=0,l,t=0;
- char c;
+ int c;
fp = fopen(TERMSDIR "/" TERMSFILE,"r");

View File

@ -0,0 +1,19 @@
$OpenBSD: patch-src_xtermset_c,v 1.1 2020/10/13 15:10:39 cwen Exp $
Fix array bounds; that caused a segfault while storing the configuration file,
also ensure EOF is properly matched on archs where char is unsigned (ppc, arm)
Index: src/xtermset.c
--- src/xtermset.c.orig
+++ src/xtermset.c
@@ -33,8 +33,8 @@
int main(int argc, char *argv[])
{
- int i,style,code,switches[2];
- char fn[2][MAXFNCHARS-1],c,*tok;
+ int i,c,style,code,switches[3];
+ char fn[3][MAXFNCHARS-1],*tok;
char line[MAXOPTCHARS+10]; /* ? */
FILE *rcfile=NULL;
argument *argptr = NULL;