summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorsten Lockert <tholo@cvs.openbsd.org>1996-08-27 03:32:34 +0000
committerThorsten Lockert <tholo@cvs.openbsd.org>1996-08-27 03:32:34 +0000
commit435a38d9dfc2ff6b7444727e9da4e521828bfbec (patch)
tree0658912be028fe05a25d1767a4f3e66adcbad8c1
parent69993b43f2f7c55a601714bcbc35bc1409fa3c89 (diff)
Ensure strings are NUL terminated after strncpy
-rw-r--r--lib/libtermlib/fillcap.c6
-rw-r--r--lib/libtermlib/getterm.c14
2 files changed, 11 insertions, 9 deletions
diff --git a/lib/libtermlib/fillcap.c b/lib/libtermlib/fillcap.c
index cc103e81cd1..f868d4e5b40 100644
--- a/lib/libtermlib/fillcap.c
+++ b/lib/libtermlib/fillcap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fillcap.c,v 1.1 1996/05/31 05:40:02 tholo Exp $ */
+/* $OpenBSD: fillcap.c,v 1.2 1996/08/27 03:32:32 tholo Exp $ */
/*
* Copyright (c) 1996 SigmaSoft, Th. Lockert <tholo@sigmasoft.com>
@@ -31,7 +31,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: fillcap.c,v 1.1 1996/05/31 05:40:02 tholo Exp $";
+static char rcsid[] = "$OpenBSD: fillcap.c,v 1.2 1996/08/27 03:32:32 tholo Exp $";
#endif
#include <stdio.h>
@@ -92,7 +92,7 @@ _ti_fillcap(term)
sprintf(buf, "%s\n$<%d>", carriage_return, new_line_delay);
else {
strncpy(buf, carriage_return, sizeof(buf) >> 1);
- buf[sizeof(buf) - 2] = '\0';
+ buf[sizeof(buf) >> 1] = '\0';
strncat(buf, "\n", sizeof(buf) - 1);
}
buf[sizeof(buf) - 1] = '\0';
diff --git a/lib/libtermlib/getterm.c b/lib/libtermlib/getterm.c
index bb97d8edc57..03cceebe9d4 100644
--- a/lib/libtermlib/getterm.c
+++ b/lib/libtermlib/getterm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getterm.c,v 1.7 1996/08/07 03:26:00 tholo Exp $ */
+/* $OpenBSD: getterm.c,v 1.8 1996/08/27 03:32:33 tholo Exp $ */
/*
* Copyright (c) 1996 SigmaSoft, Th. Lockert <tholo@sigmasoft.com>
@@ -31,7 +31,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: getterm.c,v 1.7 1996/08/07 03:26:00 tholo Exp $";
+static char rcsid[] = "$OpenBSD: getterm.c,v 1.8 1996/08/27 03:32:33 tholo Exp $";
#endif
#include <stdlib.h>
@@ -78,8 +78,8 @@ _ti_gettermcap(name)
char **fname;
char *home;
int i;
- char pathbuf[MAXPATHLEN]; /* holds raw path of filenames */
- char *pathvec[PVECSIZ]; /* to point to names in pathbuf */
+ char pathbuf[MAXPATHLEN+1]; /* holds raw path of filenames */
+ char *pathvec[PVECSIZ]; /* to point to names in pathbuf */
char *termpath;
long num;
@@ -111,6 +111,7 @@ _ti_gettermcap(name)
}
else /* user-defined name in TERMCAP */
strncpy(pathbuf, cp, MAXPATHLEN); /* still can be tokenized */
+ pathbuf[MAXPATHLEN] = '\0';
*fname++ = pathbuf; /* tokenize path into vector of names */
while (*++p)
@@ -223,8 +224,8 @@ _ti_getterminfo(name)
char **fname;
char *home;
int i;
- char pathbuf[MAXPATHLEN]; /* holds raw path of filenames */
- char *pathvec[PVECSIZ]; /* to point to names in pathbuf */
+ char pathbuf[MAXPATHLEN+1]; /* holds raw path of filenames */
+ char *pathvec[PVECSIZ]; /* to point to names in pathbuf */
char *termpath;
long num;
@@ -251,6 +252,7 @@ _ti_getterminfo(name)
} /* if no $HOME look in current directory */
strncpy(p, _PATH_INFODEF, MAXPATHLEN - (p - pathbuf));
}
+ pathbuf[MAXPATHLEN] = '\9';
*fname++ = pathbuf; /* tokenize path into vector of names */
while (*++p)