diff options
author | Thierry Deval <tdeval@cvs.openbsd.org> | 2003-04-05 00:43:21 +0000 |
---|---|---|
committer | Thierry Deval <tdeval@cvs.openbsd.org> | 2003-04-05 00:43:21 +0000 |
commit | 28816b14035bb08ad1d134a6d059b038e14eb7d8 (patch) | |
tree | 4cdd8655a357f40d8bfa4e236e802ffeb3ec3969 /lib/libedit/term.c | |
parent | 89818c6c69a0745284f6b5368cadd229bfe9c8cb (diff) |
strcpy/strcat -> strlcpy/strlcat
ok tedu@, hints by deraadt@ and millert@
Diffstat (limited to 'lib/libedit/term.c')
-rw-r--r-- | lib/libedit/term.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/libedit/term.c b/lib/libedit/term.c index c516b8a3013..c69d2b5a1df 100644 --- a/lib/libedit/term.c +++ b/lib/libedit/term.c @@ -1,4 +1,4 @@ -/* $OpenBSD: term.c,v 1.7 2002/11/29 20:13:39 deraadt Exp $ */ +/* $OpenBSD: term.c,v 1.8 2003/04/05 00:43:20 tdeval Exp $ */ /* $NetBSD: term.c,v 1.8 1997/01/23 14:02:49 mrg Exp $ */ /*- @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)term.c 8.1 (Berkeley) 6/4/93"; #else -static char rcsid[] = "$OpenBSD: term.c,v 1.7 2002/11/29 20:13:39 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: term.c,v 1.8 2003/04/05 00:43:20 tdeval Exp $"; #endif #endif /* not lint && not SCCSID */ @@ -371,7 +371,7 @@ term_alloc(el, t, cap) * New string is shorter; no need to allocate space */ if (clen <= tlen) { - (void)strcpy(*str, cap); + (void)strlcpy(*str, cap, tlen + 1); return; } @@ -379,7 +379,8 @@ term_alloc(el, t, cap) * New string is longer; see if we have enough space to append */ if (el->el_term.t_loc + 3 < TC_BUFSIZE) { - (void)strcpy(*str = &el->el_term.t_buf[el->el_term.t_loc], cap); + tlen = TC_BUFSIZE - el->el_term.t_loc; + (void)strlcpy(*str = &el->el_term.t_buf[el->el_term.t_loc], cap, tlen); el->el_term.t_loc += clen + 1; /* one for \0 */ return; } @@ -403,7 +404,8 @@ term_alloc(el, t, cap) (void)fprintf(el->el_errfile, "Out of termcap string space.\n"); return; } - (void)strcpy(*str = &el->el_term.t_buf[el->el_term.t_loc], cap); + tlen = TC_BUFSIZE - el->el_term.t_loc; + (void)strlcpy(*str = &el->el_term.t_buf[el->el_term.t_loc], cap, tlen); el->el_term.t_loc += clen + 1; /* one for \0 */ return; } /* end term_alloc */ |