use bounded string ops

This commit is contained in:
itojun 2003-07-13 07:39:39 +00:00
parent 658b0219c1
commit d90a2369ab
5 changed files with 20 additions and 19 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount_portal.c,v 1.23 2003/03/22 11:15:54 jdolecek Exp $ */
/* $NetBSD: mount_portal.c,v 1.24 2003/07/13 07:41:47 itojun Exp $ */
/*
* Copyright (c) 1992, 1993, 1994
@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\n\
#if 0
static char sccsid[] = "@(#)mount_portal.c 8.6 (Berkeley) 4/26/95";
#else
__RCSID("$NetBSD: mount_portal.c,v 1.23 2003/03/22 11:15:54 jdolecek Exp $");
__RCSID("$NetBSD: mount_portal.c,v 1.24 2003/07/13 07:41:47 itojun Exp $");
#endif
#endif /* not lint */
@ -176,7 +176,7 @@ main(argc, argv)
* Construct the listening socket
*/
un.sun_family = AF_LOCAL;
strcpy(tmpdir, _PATH_TMPPORTAL);
strlcpy(tmpdir, _PATH_TMPPORTAL, sizeof(tmpdir));
mkdtemp(tmpdir);
un.sun_len = snprintf(un.sun_path, sizeof(un.sun_path),
"%s/%s", tmpdir, _PATH_PORTAL_FILE);
@ -206,7 +206,7 @@ main(argc, argv)
daemon(0, 1);
args.pa_socket = so;
sprintf(tag, "portal:%d", getpid());
snprintf(tag, sizeof(tag), "portal:%d", getpid());
args.pa_config = tag;
rc = mount(MOUNT_PORTAL, mountpt, mntflags, &args);

View File

@ -1,4 +1,4 @@
/* $NetBSD: pt_file.c,v 1.13 2001/01/10 03:33:16 lukem Exp $ */
/* $NetBSD: pt_file.c,v 1.14 2003/07/13 07:41:48 itojun Exp $ */
/*
* Copyright (c) 1992, 1993
@ -41,7 +41,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: pt_file.c,v 1.13 2001/01/10 03:33:16 lukem Exp $");
__RCSID("$NetBSD: pt_file.c,v 1.14 2003/07/13 07:41:48 itojun Exp $");
#endif /* not lint */
#include <stdio.h>
@ -148,7 +148,7 @@ portal_file(pcr, key, v, so, fdp)
origuid = getuid();
origgid = getgid();
pbuf[0] = '/';
strcpy(pbuf + 1, key + (v[1] ? strlen(v[1]) : 0));
strlcpy(pbuf + 1, key + (v[1] ? strlen(v[1]) : 0), sizeof(pbuf) - 1);
DEBUG_SYSLOG(LOG_DEBUG, "path = %s, uid = %d, gid = %d",
pbuf, pcr->pcr_uid, pcr->pcr_gid);

View File

@ -1,4 +1,4 @@
/* $NetBSD: pt_tcp.c,v 1.15 2001/01/10 03:33:16 lukem Exp $ */
/* $NetBSD: pt_tcp.c,v 1.16 2003/07/13 07:41:48 itojun Exp $ */
/*
* Copyright (c) 1992, 1993, 1994
@ -41,7 +41,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: pt_tcp.c,v 1.15 2001/01/10 03:33:16 lukem Exp $");
__RCSID("$NetBSD: pt_tcp.c,v 1.16 2003/07/13 07:41:48 itojun Exp $");
#endif /* not lint */
#include <stdio.h>
@ -97,15 +97,15 @@ portal_tcp(pcr, key, v, kso, fdp)
if (q == 0 || q - p >= sizeof(host))
return (EINVAL);
*q = '\0';
strcpy(host, p);
if (strlcpy(host, p, sizeof(host)) >= sizeof(host))
return (EINVAL);
p = q + 1;
q = strchr(p, '/');
if (q)
*q = '\0';
if (strlen(p) >= sizeof(port))
if (strlcpy(port, p, sizeof(port)) >= sizeof(port))
return (EINVAL);
strcpy(port, p);
if (q) {
p = q + 1;
if (strcmp(p, "priv") == 0) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs.c,v 1.27 2003/04/02 10:39:31 fvdl Exp $ */
/* $NetBSD: lfs.c,v 1.28 2003/07/13 07:39:39 itojun Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)lfs.c 8.5 (Berkeley) 5/24/95";
#else
__RCSID("$NetBSD: lfs.c,v 1.27 2003/04/02 10:39:31 fvdl Exp $");
__RCSID("$NetBSD: lfs.c,v 1.28 2003/07/13 07:39:39 itojun Exp $");
#endif
#endif /* not lint */
@ -904,8 +904,9 @@ make_lfs(int fd, struct disklabel *lp, struct partition *partp, int minfree,
for (i = 0; i < LFS_MAXNUMSB; i++) {
seg_addr = lfsp->lfs_sboffs[i];
sprintf(tbuf, "%lld%s ", (long long)fsbtodb(lfsp, seg_addr),
(i == LFS_MAXNUMSB - 1 ? "" : ","));
snprintf(tbuf, sizeof(tbuf), "%lld%s ",
(long long)fsbtodb(lfsp, seg_addr),
(i == LFS_MAXNUMSB - 1 ? "" : ","));
ww = strlen(tbuf);
curw += ww;
if (curw + ww > 78) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: newfs.c,v 1.10 2002/12/12 11:45:17 scw Exp $ */
/* $NetBSD: newfs.c,v 1.11 2003/07/13 07:39:40 itojun Exp $ */
/*-
* Copyright (c) 1989, 1992, 1993
@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1992, 1993\n\
#if 0
static char sccsid[] = "@(#)newfs.c 8.5 (Berkeley) 5/24/95";
#else
__RCSID("$NetBSD: newfs.c,v 1.10 2002/12/12 11:45:17 scw Exp $");
__RCSID("$NetBSD: newfs.c,v 1.11 2003/07/13 07:39:40 itojun Exp $");
#endif
#endif /* not lint */
@ -408,7 +408,7 @@ rewritelabel(char *s, int fd, struct disklabel *lp)
/*
* Make name for 'c' partition.
*/
strcpy(specname, s);
strlcpy(specname, s, sizeof(specname));
cp = specname + strlen(specname) - 1;
if (!isdigit(*cp))
*cp = 'c';