diff options
Diffstat (limited to 'lib/libocurses/termcap.c')
-rw-r--r-- | lib/libocurses/termcap.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/lib/libocurses/termcap.c b/lib/libocurses/termcap.c index c060f7fd4a0..1eb3baf117e 100644 --- a/lib/libocurses/termcap.c +++ b/lib/libocurses/termcap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: termcap.c,v 1.6 2000/10/09 22:01:26 millert Exp $ */ +/* $OpenBSD: termcap.c,v 1.7 2003/04/04 18:39:12 millert Exp $ */ /* $NetBSD: termcap.c,v 1.7 1995/06/05 19:45:52 pk Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)termcap.c 8.1 (Berkeley) 6/4/93"; #else -static char rcsid[] = "$OpenBSD: termcap.c,v 1.6 2000/10/09 22:01:26 millert Exp $"; +static char rcsid[] = "$OpenBSD: termcap.c,v 1.7 2003/04/04 18:39:12 millert Exp $"; #endif #endif /* not lint */ @@ -108,17 +108,10 @@ tgetent(bp, name) } else if (!cp || *cp != '/') { /* TERMCAP holds an entry */ if ((termpath = getenv("TERMPATH")) != NULL) strlcpy(pathbuf, termpath, sizeof(pathbuf)); - else { - if ((home = getenv("HOME")) != NULL && *home != '\0' && - strlen(home) + sizeof(_PATH_DEF) < - sizeof(pathbuf)) { - sprintf(pathbuf, "%s/%s", home, - _PATH_DEF); - } else { - strlcpy(pathbuf, _PATH_DEF, - sizeof(pathbuf)); - } - } + else if ((home = getenv("HOME")) == NULL || *home == '\0' || + snprintf(pathbuf, sizeof(pathbuf), "%s/%s", home, + _PATH_DEF) >= sizeof(pathbuf)) + strlcpy(pathbuf, _PATH_DEF, sizeof(pathbuf)); } else { /* user-defined path in TERMCAP */ /* still can be tokenized */ strlcpy(pathbuf, cp, sizeof(pathbuf)); @@ -227,7 +220,7 @@ tgetstr(id, area) if ((i = cgetstr(tbuf, ids, &s)) < 0) return NULL; - strcpy(*area, s); + strlcpy(*area, s, 1024); *area += i + 1; return (s); } |