diff options
author | Thorsten Lockert <tholo@cvs.openbsd.org> | 1996-09-03 05:16:10 +0000 |
---|---|---|
committer | Thorsten Lockert <tholo@cvs.openbsd.org> | 1996-09-03 05:16:10 +0000 |
commit | 1097f6f628ff158181af7aa67f3f74aac76a5c64 (patch) | |
tree | 1063caab5f7ec930b193649089251b50db5ceed9 /lib/libterm | |
parent | 004f58070bc480fc006eaeb44a94f3a6c55000b5 (diff) |
Protect against buffer overflow
Diffstat (limited to 'lib/libterm')
-rw-r--r-- | lib/libterm/termcap.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libterm/termcap.c b/lib/libterm/termcap.c index 2eb5d31cdd9..8e11888836b 100644 --- a/lib/libterm/termcap.c +++ b/lib/libterm/termcap.c @@ -106,8 +106,9 @@ tgetent(bp, name) else { if ((home = getenv("HOME")) != NULL) { /* set up default */ - p += strlen(home); /* path, looking in */ - strcpy(pathbuf, home); /* $HOME first */ + strncpy(pathbuf, home, PBUFSIZ - strlen(_PATH_DEF) - 1); /* $HOME first */ + pathbuf[PBUFSIZ - strlen(_PATH_DEF) - 1] = '\0'; + p += strlen(pathbuf); /* path, looking in */ *p++ = '/'; } /* if no $HOME look in current directory */ strncpy(p, _PATH_DEF, PBUFSIZ - (p - pathbuf)); @@ -115,6 +116,7 @@ tgetent(bp, name) } else /* user-defined name in TERMCAP */ strncpy(pathbuf, cp, PBUFSIZ); /* still can be tokenized */ + pathbuf[PBUFSIZ] = '\0'; *fname++ = pathbuf; /* tokenize path into vector of names */ while (*++p) |