diff options
author | Thorsten Lockert <tholo@cvs.openbsd.org> | 1996-06-21 04:37:33 +0000 |
---|---|---|
committer | Thorsten Lockert <tholo@cvs.openbsd.org> | 1996-06-21 04:37:33 +0000 |
commit | f7e18851211b7e33476068a7d21d25313c19e56b (patch) | |
tree | 64dc6b6e3557411bb000cd200d6010a328e6d51e /lib/libterm | |
parent | c7ebc8ac7315aef58d31a7495fdab5e9309b763b (diff) |
Make sure we don't write more than 1024 bytes into the buffer passed to
tgetent(3); truncate the capability string if this happens.
Diffstat (limited to 'lib/libterm')
-rw-r--r-- | lib/libterm/termcap.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/libterm/termcap.c b/lib/libterm/termcap.c index 3b0a87a7f51..2109744f990 100644 --- a/lib/libterm/termcap.c +++ b/lib/libterm/termcap.c @@ -139,8 +139,13 @@ tgetent(bp, name) dummy = NULL; i = cgetent(&dummy, pathvec, name); - if (i == 0) - strcpy(bp, dummy); + if (i == 0) { + strncpy(bp, dummy, 1023); + bp[1023] = '\0'; + if ((cp = strrchr(bp, ':')) != NULL) + if (cp[1] != '\0') + cp[1] = '\0'; + } if (dummy) free(dummy); |