Apply by doing:
    cd /usr/src/lib
    patch < termcap.patch
    cd libcurses; make && make install
    cd ../libocurses; make && make install

Index: libcurses/read_termcap.c
===================================================================
RCS file: /cvs/src/lib/libcurses/read_termcap.c,v
retrieving revision 1.5
diff -u -r1.5 read_termcap.c
--- read_termcap.c	1998/10/08 04:20:00	1.5
+++ read_termcap.c	1999/01/15 05:02:41
@@ -802,7 +802,10 @@
 	 * searched instead.  The path is found in the TERMPATH variable, or
 	 * becomes "$HOME/.termcap /etc/termcap" if no TERMPATH exists.
 	 */
-	if (!issetugid() && !is_pathname(cp)) {	/* no TERMCAP or it holds an entry */
+#define	MY_PATH_DEF	"/etc/termcap /usr/share/misc/termcap"
+	if (issetugid())
+		strlcpy(pathbuf, MY_PATH_DEF, PBUFSIZ);
+	else if (!is_pathname(cp)) {	/* no TERMCAP or it holds an entry */
 		if ((termpath = getenv("TERMPATH")) != 0) {
 			strlcpy(pathbuf, termpath, PBUFSIZ);
 		} else {
@@ -812,8 +815,8 @@
 				strcpy(pathbuf, home);	/* $HOME first */
 				*p++ = '/';
 			}	/* if no $HOME look in current directory */
-#define	MY_PATH_DEF	".termcap /etc/termcap /usr/share/misc/termcap"
-			strlcpy(p, MY_PATH_DEF, (size_t)(PBUFSIZ - (p - pathbuf)));
+			strlcpy(p, ".termcap " MY_PATH_DEF,
+			    (size_t)(PBUFSIZ - (p - pathbuf)));
 		}
 	}
 	else				/* user-defined name in TERMCAP */
@@ -971,7 +974,7 @@
 	char	pathbuf[PATH_MAX];
 
 	termpaths[filecount] = 0;
-	if (!issetugid() && (tc = getenv("TERMCAP")) != 0)
+	if ((tc = getenv("TERMCAP")) != 0 && (!issetugid() || !is_pathname(tc)))
 	{
 		if (is_pathname(tc))	/* interpret as a filename */
 		{
Index: libocurses/pathnames.h
===================================================================
RCS file: /cvs/src/lib/libocurses/pathnames.h,v
retrieving revision 1.1
diff -u -r1.1 pathnames.h
--- pathnames.h	1998/07/23 21:10:26	1.1
+++ pathnames.h	1999/01/15 05:12:08
@@ -36,4 +36,5 @@
  *	@(#)pathnames.h	8.1 (Berkeley) 6/4/93
  */
 
-#define	_PATH_DEF	".termcap /usr/share/misc/termcap"
+#define _PATH_TERMCAP	"/usr/share/misc/termcap"
+#define _PATH_DEF	__CONCAT(".termcap ",_PATH_TERMCAP)
Index: libocurses/termcap.c
===================================================================
RCS file: /cvs/src/lib/libocurses/termcap.c,v
retrieving revision 1.2
diff -u -r1.2 termcap.c
--- termcap.c	1998/10/08 04:31:29	1.2
+++ termcap.c	1999/01/15 05:02:41
@@ -50,6 +50,7 @@
 #include <ctype.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 #include <curses.h>
 #include "pathnames.h"
 
@@ -90,46 +91,42 @@
 	fname = pathvec;
 	pvec = pathvec;
 	tbuf = bp;
-	p = pathbuf;
 
-	if (!issetugid()) {
-		cp = getenv("TERMCAP");
-		/*
-		 * TERMCAP can have one of two things in it. It can be the name
-		 * of a file to use instead of /usr/share/misc/termcap. In this
-		 * case it better start with a "/". Or it can be an entry to
-		 * use so we don't have to read the file. In this case it
-		 * has to already have the newlines crunched out.  If TERMCAP
-		 * does not hold a file name then a path of names is searched
-		 * instead.  The path is found in the TERMPATH variable, or
-		 * becomes "$HOME/.termcap /usr/share/misc/termcap" if no
-		 * TERMPATH exists.
-		 */
-		if (!cp || *cp != '/') { /* no TERMCAP or it holds an entry */
-			if ((termpath = getenv("TERMPATH")) != NULL)
-				strncpy(pathbuf, termpath, sizeof(pathbuf) - 1);
-			else {
-				if ((home = getenv("HOME")) != NULL) {
-					/* set up default */
-					/* $HOME first */
-					strncpy(pathbuf, home, sizeof(pathbuf) -
-					    1 - strlen(_PATH_DEF) - 1);
-					pathbuf[sizeof(pathbuf) - 1 -
-					    strlen(_PATH_DEF) - 1] = '\0';
-					p += strlen(pathbuf);	/* path, looking in */
-					*p++ = '/';
-				}	/* if no $HOME look in current dir */
-				strncpy(p, _PATH_DEF, sizeof(pathbuf) -1 -
-				    (p - pathbuf));
+	cp = getenv("TERMCAP");
+	/*
+	 * TERMCAP can have one of two things in it. It can be the name
+	 * of a file to use instead of /usr/share/misc/termcap. In this
+	 * case it better start with a "/". Or it can be an entry to use
+	 * so we don't have to read the file. In this case it has to
+	 * already have the newlines crunched out.  If TERMCAP does not
+	 * hold a file name then a path of names is searched instead.
+	 * The path is found in the TERMPATH variable, or becomes
+	 * "$HOME/.termcap /usr/share/misc/termcap" if no TERMPATH exists.
+	 */
+	if (issetugid()) {
+		strlcpy(pathbuf, _PATH_TERMCAP, sizeof(pathbuf));
+	} else if (!cp || *cp != '/') { /* no TERMCAP or it holds an entry */
+		if ((termpath = getenv("TERMPATH")) != NULL)
+			strlcpy(pathbuf, termpath, sizeof(pathbuf));
+		else {
+			if ((home = getenv("HOME")) != NULL &&
+			    strlen(home) + sizeof(_PATH_DEF) <
+			    sizeof(pathbuf)) {
+				sprintf(pathbuf, "%s/%s", home,
+				    _PATH_DEF);
+			} else {
+				strlcpy(pathbuf, _PATH_DEF,
+				    sizeof(pathbuf));
 			}
-		} else {		/* user-defined name in TERMCAP */
-			/* still can be tokenized */
-			strncpy(pathbuf, cp, sizeof(pathbuf) - 1);
 		}
-		pathbuf[sizeof(pathbuf) - 1] = '\0';
-
-		*fname++ = pathbuf;	/* tokenize path into vector of names */
+	} else {		/* user-defined path in TERMCAP */
+		/* still can be tokenized */
+		strlcpy(pathbuf, cp, sizeof(pathbuf));
 	}
+	*fname++ = pathbuf;	/* tokenize path into vector of names */
+
+	/* split pathbuf into a vector of paths */
+	p = pathbuf;
 	while (*++p)
 		if (*p == ' ' || *p == ':') {
 			*p = '\0';
@@ -153,8 +150,7 @@
 	i = cgetent(&dummy, pathvec, name);
 	
 	if (i == 0 && bp != NULL) {
-		strncpy(bp, dummy, 1023);
-		bp[1023] = '\0';
+		strlcpy(bp, dummy, 1024);
 		if ((cp = strrchr(bp, ':')) != NULL)
 			if (cp[1] != '\0')
 				cp[1] = '\0';
