diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-03-13 15:47:35 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-03-13 15:47:35 +0000 |
commit | 6c0bb8c7a42d42230f0786e8b4ca6567ded4fc69 (patch) | |
tree | 549f35a4cc07f24fe880b6d321af9a23b64cdbef | |
parent | 1e46612221e29a3f44b51938a54918044e96afd0 (diff) |
a few more strlcy; ok from beck & ho
-rw-r--r-- | lib/libc/string/__strerror.c | 6 | ||||
-rw-r--r-- | lib/libc/string/__strsignal.c | 6 | ||||
-rw-r--r-- | lib/libc/time/ialloc.c | 8 | ||||
-rw-r--r-- | lib/libc/time/localtime.c | 12 | ||||
-rw-r--r-- | lib/libc/time/strftime.c | 4 |
5 files changed, 19 insertions, 17 deletions
diff --git a/lib/libc/string/__strerror.c b/lib/libc/string/__strerror.c index ae19ab33654..7301a7bc84c 100644 --- a/lib/libc/string/__strerror.c +++ b/lib/libc/string/__strerror.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: __strerror.c,v 1.8 2001/12/08 20:37:32 deraadt Exp $"; +static char *rcsid = "$OpenBSD: __strerror.c,v 1.9 2003/03/13 15:47:33 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #ifdef NLS @@ -98,9 +98,9 @@ __strerror(num, buf) #ifdef NLS strlcpy(buf, catgets(catd, 1, 0xffff, UPREFIX), NL_TEXTMAX); #else - strcpy(buf, UPREFIX); + strlcpy(buf, UPREFIX, NL_TEXTMAX); #endif - strncat(buf, itoa(errnum), NL_TEXTMAX-strlen(buf)-1); + strlcat(buf, itoa(errnum), NL_TEXTMAX); errno = EINVAL; } diff --git a/lib/libc/string/__strsignal.c b/lib/libc/string/__strsignal.c index 4ca5bad3c0f..26168722326 100644 --- a/lib/libc/string/__strsignal.c +++ b/lib/libc/string/__strsignal.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: __strsignal.c,v 1.6 2001/06/27 00:58:56 lebel Exp $"; +static char *rcsid = "$OpenBSD: __strsignal.c,v 1.7 2003/03/13 15:47:33 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #ifdef NLS @@ -89,9 +89,9 @@ __strsignal(num, buf) #ifdef NLS strlcpy(buf, catgets(catd, 1, 0xffff, UPREFIX), NL_TEXTMAX); #else - strcpy(buf, UPREFIX); + strlcpy(buf, UPREFIX, NL_TEXTMAX); #endif - strncat(buf, itoa(signum), NL_TEXTMAX-strlen(buf)-1); + strlcat(buf, itoa(signum), NL_TEXTMAX); } #ifdef NLS diff --git a/lib/libc/time/ialloc.c b/lib/libc/time/ialloc.c index 71f93c7eeae..10055e77559 100644 --- a/lib/libc/time/ialloc.c +++ b/lib/libc/time/ialloc.c @@ -5,7 +5,7 @@ #if defined(LIBC_SCCS) && !defined(lint) && !defined(NOID) static char elsieid[] = "@(#)ialloc.c 8.29"; -static char rcsid[] = "$OpenBSD: ialloc.c,v 1.7 2003/02/14 18:24:53 millert Exp $"; +static char rcsid[] = "$OpenBSD: ialloc.c,v 1.8 2003/03/13 15:47:34 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ /*LINTLIBRARY*/ @@ -53,6 +53,7 @@ const char * const new; { register char * result; register int oldsize, newsize; + int size; newsize = (new == NULL) ? 0 : strlen(new); if (old == NULL) @@ -61,9 +62,10 @@ const char * const new; return old; else oldsize = strlen(old); - if ((result = irealloc(old, oldsize + newsize + 1)) != NULL) + size = oldsize + newsize + 1; + if ((result = irealloc(old, size)) != NULL) if (new != NULL) - (void) strcpy(result + oldsize, new); + (void) strlcpy(result + oldsize, new, newsize + 1); else free(old); return result; diff --git a/lib/libc/time/localtime.c b/lib/libc/time/localtime.c index 88821b7d954..9690da0f63e 100644 --- a/lib/libc/time/localtime.c +++ b/lib/libc/time/localtime.c @@ -5,7 +5,7 @@ #if defined(LIBC_SCCS) && !defined(lint) && !defined(NOID) static char elsieid[] = "@(#)localtime.c 7.75"; -static char rcsid[] = "$OpenBSD: localtime.c,v 1.21 2002/04/04 19:12:09 millert Exp $"; +static char rcsid[] = "$OpenBSD: localtime.c,v 1.22 2003/03/13 15:47:34 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ /* @@ -302,9 +302,9 @@ register struct state * const sp; return -1; if ((strlen(p) + strlen(name) + 1) >= sizeof fullname) return -1; - (void) strcpy(fullname, p); - (void) strcat(fullname, "/"); - (void) strcat(fullname, name); + (void) strlcpy(fullname, p, sizeof fullname); + (void) strlcat(fullname, "/", sizeof fullname); + (void) strlcat(fullname, name, sizeof fullname); /* ** Set doaccess if '.' (as in "../") shows up in name. */ @@ -972,7 +972,7 @@ tzset_basic P((void)) return; lcl_is_set = strlen(name) < sizeof lcl_TZname; if (lcl_is_set) - (void) strcpy(lcl_TZname, name); + (void) strlcpy(lcl_TZname, name, sizeof lcl_TZname); #ifdef ALL_STATE if (lclptr == NULL) { @@ -993,7 +993,7 @@ tzset_basic P((void)) lclptr->ttis[0].tt_isdst = 0; lclptr->ttis[0].tt_gmtoff = 0; lclptr->ttis[0].tt_abbrind = 0; - (void) strcpy(lclptr->chars, gmt); + (void) strlcpy(lclptr->chars, gmt, sizeof lclptr->chars); } else if (tzload(name, lclptr) != 0) if (name[0] == ':' || tzparse(name, lclptr, FALSE) != 0) (void) gmtload(lclptr); diff --git a/lib/libc/time/strftime.c b/lib/libc/time/strftime.c index 1444b8fbfe8..e92740a58d3 100644 --- a/lib/libc/time/strftime.c +++ b/lib/libc/time/strftime.c @@ -1,6 +1,6 @@ #if defined(LIBC_SCCS) && !defined(lint) && !defined(NOID) static char elsieid[] = "@(#)strftime.c 7.64"; -static char *rcsid = "$OpenBSD: strftime.c,v 1.11 2002/06/19 14:56:28 millert Exp $"; +static char *rcsid = "$OpenBSD: strftime.c,v 1.12 2003/03/13 15:47:34 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #include "private.h" @@ -692,7 +692,7 @@ _loc P((void)) goto bad_locale; } lbuf = nlbuf; - (void) strcpy(lbuf, name); + (void) strlcpy(lbuf, name, bufsize); p = lbuf + namesize; plim = p + st.st_size; if (read(fd, p, (size_t) st.st_size) != st.st_size) |