Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin use bounded string ops
details: https://anonhg.NetBSD.org/src/rev/7d528a4a1815
branches: trunk
changeset: 549364:7d528a4a1815
user: itojun <itojun%NetBSD.org@localhost>
date: Sun Jul 13 07:39:39 2003 +0000
description:
use bounded string ops
diffstat:
sbin/mount_portal/mount_portal.c | 8 ++++----
sbin/mount_portal/pt_file.c | 6 +++---
sbin/mount_portal/pt_tcp.c | 10 +++++-----
sbin/newfs_lfs/lfs.c | 9 +++++----
sbin/newfs_lfs/newfs.c | 6 +++---
5 files changed, 20 insertions(+), 19 deletions(-)
diffs (157 lines):
diff -r 42cb88ea653e -r 7d528a4a1815 sbin/mount_portal/mount_portal.c
--- a/sbin/mount_portal/mount_portal.c Sun Jul 13 07:38:12 2003 +0000
+++ b/sbin/mount_portal/mount_portal.c Sun Jul 13 07:39:39 2003 +0000
@@ -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 @@
#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 @@
* 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 @@
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);
diff -r 42cb88ea653e -r 7d528a4a1815 sbin/mount_portal/pt_file.c
--- a/sbin/mount_portal/pt_file.c Sun Jul 13 07:38:12 2003 +0000
+++ b/sbin/mount_portal/pt_file.c Sun Jul 13 07:39:39 2003 +0000
@@ -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 @@
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);
diff -r 42cb88ea653e -r 7d528a4a1815 sbin/mount_portal/pt_tcp.c
--- a/sbin/mount_portal/pt_tcp.c Sun Jul 13 07:38:12 2003 +0000
+++ b/sbin/mount_portal/pt_tcp.c Sun Jul 13 07:39:39 2003 +0000
@@ -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 @@
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) {
diff -r 42cb88ea653e -r 7d528a4a1815 sbin/newfs_lfs/lfs.c
--- a/sbin/newfs_lfs/lfs.c Sun Jul 13 07:38:12 2003 +0000
+++ b/sbin/newfs_lfs/lfs.c Sun Jul 13 07:39:39 2003 +0000
@@ -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 @@
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) {
diff -r 42cb88ea653e -r 7d528a4a1815 sbin/newfs_lfs/newfs.c
--- a/sbin/newfs_lfs/newfs.c Sun Jul 13 07:38:12 2003 +0000
+++ b/sbin/newfs_lfs/newfs.c Sun Jul 13 07:39:39 2003 +0000
@@ -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 @@
#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 @@
/*
* Make name for 'c' partition.
*/
- strcpy(specname, s);
+ strlcpy(specname, s, sizeof(specname));
cp = specname + strlen(specname) - 1;
if (!isdigit(*cp))
*cp = 'c';
Home |
Main Index |
Thread Index |
Old Index