make sure to bound string operation by strlcpy
(there are bunch of "strcpy is safe" comments, i think we should change them to strlcpy as much as possible)
This commit is contained in:
parent
ca7918fced
commit
233424cdc2
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: __glob13.c,v 1.23 2001/09/18 16:37:26 christos Exp $ */
|
||||
/* $NetBSD: __glob13.c,v 1.24 2002/11/17 20:49:33 itojun Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
|
@ -41,7 +41,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)glob.c 8.3 (Berkeley) 10/13/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: __glob13.c,v 1.23 2001/09/18 16:37:26 christos Exp $");
|
||||
__RCSID("$NetBSD: __glob13.c,v 1.24 2002/11/17 20:49:33 itojun Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
@ -926,7 +926,7 @@ g_opendir(str, pglob)
|
|||
_DIAGASSERT(pglob != NULL);
|
||||
|
||||
if (!*str)
|
||||
(void)strcpy(buf, ".");
|
||||
(void)strlcpy(buf, ".", sizeof(buf));
|
||||
else {
|
||||
if (g_Ctoc(str, buf, sizeof(buf)))
|
||||
return NULL;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: getcwd.c,v 1.27 2002/11/17 01:51:24 itojun Exp $ */
|
||||
/* $NetBSD: getcwd.c,v 1.28 2002/11/17 20:49:33 itojun Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1991, 1993, 1995
|
||||
|
@ -41,7 +41,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)getcwd.c 8.5 (Berkeley) 2/7/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: getcwd.c,v 1.27 2002/11/17 01:51:24 itojun Exp $");
|
||||
__RCSID("$NetBSD: getcwd.c,v 1.28 2002/11/17 20:49:33 itojun Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
@ -95,7 +95,7 @@ realpath(path, resolved)
|
|||
|
||||
/* Save the starting point. */
|
||||
if ((fd = open(".", O_RDONLY)) < 0) {
|
||||
(void)strcpy(resolved, ".");
|
||||
(void)strlcpy(resolved, ".", MAXPATHLEN);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: utmp.c,v 1.4 2002/08/01 23:46:37 nathanw Exp $ */
|
||||
/* $NetBSD: utmp.c,v 1.5 2002/11/17 20:49:33 itojun Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
|
@ -38,7 +38,7 @@
|
|||
#include <sys/cdefs.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: utmp.c,v 1.4 2002/08/01 23:46:37 nathanw Exp $");
|
||||
__RCSID("$NetBSD: utmp.c,v 1.5 2002/11/17 20:49:33 itojun Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -93,7 +93,7 @@ utmpname(const char *fname)
|
|||
if (fname[len - 1] == 'x')
|
||||
return 0;
|
||||
|
||||
(void)strcpy(utfile, fname);
|
||||
(void)strlcpy(utfile, fname, sizeof(utfile));
|
||||
endutent();
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: utmpx.c,v 1.14 2002/10/25 20:42:02 wiz Exp $ */
|
||||
/* $NetBSD: utmpx.c,v 1.15 2002/11/17 20:49:33 itojun Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
|
@ -38,7 +38,7 @@
|
|||
#include <sys/cdefs.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: utmpx.c,v 1.14 2002/10/25 20:42:02 wiz Exp $");
|
||||
__RCSID("$NetBSD: utmpx.c,v 1.15 2002/11/17 20:49:33 itojun Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -338,7 +338,7 @@ utmpxname(const char *fname)
|
|||
if (fname[len - 1] != 'x')
|
||||
return 0;
|
||||
|
||||
(void)strcpy(utfile, fname);
|
||||
(void)strlcpy(utfile, fname, sizeof(utfile));
|
||||
endutxent();
|
||||
return 1;
|
||||
}
|
||||
|
@ -393,7 +393,7 @@ lastlogxname(const char *fname)
|
|||
if (fname[len - 1] != 'x')
|
||||
return 0;
|
||||
|
||||
(void)strcpy(llfile, fname);
|
||||
(void)strlcpy(llfile, fname, sizeof(llfile));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: inet_net_ntop.c,v 1.18 2002/11/11 18:02:14 thorpej Exp $ */
|
||||
/* $NetBSD: inet_net_ntop.c,v 1.19 2002/11/17 20:49:33 itojun Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996,1999 by Internet Software Consortium.
|
||||
|
@ -22,7 +22,7 @@
|
|||
#if 0
|
||||
static const char rcsid[] = "Id: inet_net_ntop.c,v 1.8 2001/09/27 15:08:36 marka Exp ";
|
||||
#else
|
||||
__RCSID("$NetBSD: inet_net_ntop.c,v 1.18 2002/11/11 18:02:14 thorpej Exp $");
|
||||
__RCSID("$NetBSD: inet_net_ntop.c,v 1.19 2002/11/17 20:49:33 itojun Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -300,7 +300,7 @@ inet_net_ntop_ipv6(const u_char *src, int bits, char *dst, size_t size)
|
|||
snprintf(cp, ep - cp, "/%u", bits);
|
||||
if (strlen(outbuf) + 1 > size)
|
||||
goto emsgsize;
|
||||
strcpy(dst, outbuf);
|
||||
strlcpy(dst, outbuf, size);
|
||||
|
||||
return (dst);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: inet_ntoa.c,v 1.9 2000/04/23 16:59:12 itojun Exp $ */
|
||||
/* $NetBSD: inet_ntoa.c,v 1.10 2002/11/17 20:49:33 itojun Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
|
@ -38,7 +38,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)inet_ntoa.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: inet_ntoa.c,v 1.9 2000/04/23 16:59:12 itojun Exp $");
|
||||
__RCSID("$NetBSD: inet_ntoa.c,v 1.10 2002/11/17 20:49:33 itojun Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
@ -62,7 +62,7 @@ __weak_alias(inet_ntoa,_inet_ntoa)
|
|||
inet_ntoa(struct in_addr in) {
|
||||
static char ret[18];
|
||||
|
||||
strcpy(ret, "[inet_ntoa error]");
|
||||
strlcpy(ret, "[inet_ntoa error]", sizeof(ret));
|
||||
(void) inet_ntop(AF_INET, &in, ret, sizeof ret);
|
||||
return (ret);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rcmd.c,v 1.50 2002/11/17 01:51:25 itojun Exp $ */
|
||||
/* $NetBSD: rcmd.c,v 1.51 2002/11/17 20:49:33 itojun Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 Matthew R. Green.
|
||||
|
@ -39,7 +39,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: rcmd.c,v 1.50 2002/11/17 01:51:25 itojun Exp $");
|
||||
__RCSID("$NetBSD: rcmd.c,v 1.51 2002/11/17 20:49:33 itojun Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
@ -274,7 +274,7 @@ resrcmd(res, ahost, rport, locuser, remuser, cmd, fd2p)
|
|||
hbuf[0] = '\0';
|
||||
if (getnameinfo(r->ai_addr, r->ai_addrlen,
|
||||
hbuf, sizeof(hbuf), NULL, 0, niflags) != 0)
|
||||
strcpy(hbuf, "(invalid)");
|
||||
strlcpy(hbuf, "(invalid)", sizeof(hbuf));
|
||||
warnx("rcmd: connect to address %s", hbuf);
|
||||
errno = oerrno;
|
||||
perror(0);
|
||||
|
@ -282,7 +282,7 @@ resrcmd(res, ahost, rport, locuser, remuser, cmd, fd2p)
|
|||
hbuf[0] = '\0';
|
||||
if (getnameinfo(r->ai_addr, r->ai_addrlen,
|
||||
hbuf, sizeof(hbuf), NULL, 0, niflags) != 0)
|
||||
strcpy(hbuf, "(invalid)");
|
||||
strlcpy(hbuf, "(invalid)", sizeof(hbuf));
|
||||
(void)fprintf(stderr, "Trying %s...\n", hbuf);
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: res_send.c,v 1.35 2002/11/11 20:24:38 thorpej Exp $ */
|
||||
/* $NetBSD: res_send.c,v 1.36 2002/11/17 20:49:33 itojun Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1985, 1989, 1993
|
||||
|
@ -59,7 +59,7 @@
|
|||
static char sccsid[] = "@(#)res_send.c 8.1 (Berkeley) 6/4/93";
|
||||
static char rcsid[] = "Id: res_send.c,v 8.13 1997/06/01 20:34:37 vixie Exp ";
|
||||
#else
|
||||
__RCSID("$NetBSD: res_send.c,v 1.35 2002/11/11 20:24:38 thorpej Exp $");
|
||||
__RCSID("$NetBSD: res_send.c,v 1.36 2002/11/17 20:49:33 itojun Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
@ -146,8 +146,8 @@ static int af = 0; /* address family of socket */
|
|||
if (getnameinfo(address, (size_t)address->sa_len, abuf,
|
||||
sizeof(abuf), pbuf, sizeof(pbuf),
|
||||
NI_NUMERICHOST|NI_NUMERICSERV|NI_WITHSCOPEID) != 0) {
|
||||
strcpy(abuf, "?");
|
||||
strcpy(pbuf, "?");
|
||||
strlcpy(abuf, "?", sizeof(abuf));
|
||||
strlcpy(pbuf, "?", sizeof(pbuf));
|
||||
}
|
||||
fprintf(file, "res_send: %s ([%s].%s): %s\n",
|
||||
string, abuf, pbuf, strerror(error));
|
||||
|
|
Loading…
Reference in New Issue