summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-12-16 17:11:44 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-12-16 17:11:44 +0000
commita30b546dca5879eb3e1d69bd0f307e6b85a62050 (patch)
tree78db3106ae7e7571e668906e4de1e2d24d50c332 /sbin
parent7cd754d04eab0796fee90fb5d2fc6d2691799fce (diff)
does noone know how to use strncat correctly?
Diffstat (limited to 'sbin')
-rw-r--r--sbin/dump/main.c9
-rw-r--r--sbin/mount_ados/mount_ados.c8
-rw-r--r--sbin/mount_msdos/mount_msdos.c8
-rw-r--r--sbin/restore/dirs.c6
-rw-r--r--sbin/restore/interactive.c7
5 files changed, 20 insertions, 18 deletions
diff --git a/sbin/dump/main.c b/sbin/dump/main.c
index 2bc57cd30ed..7975d557052 100644
--- a/sbin/dump/main.c
+++ b/sbin/dump/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.10 1996/09/14 19:28:58 deraadt Exp $ */
+/* $OpenBSD: main.c,v 1.11 1996/12/16 17:11:32 deraadt Exp $ */
/* $NetBSD: main.c,v 1.8 1996/03/15 22:39:32 scottr Exp $ */
/*-
@@ -511,10 +511,11 @@ rawname(cp)
if (dp == NULL)
return (NULL);
*dp = '\0';
- (void)strncpy(rawbuf, cp, MAXPATHLEN);
+ (void)strncpy(rawbuf, cp, MAXPATHLEN-1);
+ rawbuf[MAXPATHLEN-1] = '\0';
*dp = '/';
- (void)strncat(rawbuf, "/r", MAXPATHLEN - 1 - strlen(rawbuf));
- (void)strncat(rawbuf, dp + 1, MAXPATHLEN - 1 - strlen(rawbuf));
+ (void)strncat(rawbuf, "/r", MAXPATHLEN - strlen(rawbuf));
+ (void)strncat(rawbuf, dp + 1, MAXPATHLEN - strlen(rawbuf));
return (rawbuf);
}
diff --git a/sbin/mount_ados/mount_ados.c b/sbin/mount_ados/mount_ados.c
index f68882feff7..52105cb3135 100644
--- a/sbin/mount_ados/mount_ados.c
+++ b/sbin/mount_ados/mount_ados.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount_ados.c,v 1.3 1996/06/23 14:31:14 deraadt Exp $ */
+/* $OpenBSD: mount_ados.c,v 1.4 1996/12/16 17:11:36 deraadt Exp $ */
/* $NetBSD: mount_ados.c,v 1.5 1996/04/13 01:30:59 jtc Exp $ */
/*
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: mount_ados.c,v 1.3 1996/06/23 14:31:14 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: mount_ados.c,v 1.4 1996/12/16 17:11:36 deraadt Exp $";
#endif /* not lint */
#include <sys/cdefs.h>
@@ -106,8 +106,8 @@ main(argc, argv)
warnx("\"%s\" is a relative path.", dir);
if (getcwd(ndir, sizeof(ndir)) == NULL)
err(1, "getcwd");
- strncat(ndir, "/", sizeof(ndir) - strlen(ndir) - 1);
- strncat(ndir, dir, sizeof(ndir) - strlen(ndir) - 1);
+ strncat(ndir, "/", sizeof(ndir) - strlen(ndir));
+ strncat(ndir, dir, sizeof(ndir) - strlen(ndir));
dir = ndir;
warnx("using \"%s\" instead.", dir);
}
diff --git a/sbin/mount_msdos/mount_msdos.c b/sbin/mount_msdos/mount_msdos.c
index fb13e8f90a8..a223f2271f3 100644
--- a/sbin/mount_msdos/mount_msdos.c
+++ b/sbin/mount_msdos/mount_msdos.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount_msdos.c,v 1.7 1996/12/09 13:40:55 deraadt Exp $ */
+/* $OpenBSD: mount_msdos.c,v 1.8 1996/12/16 17:11:38 deraadt Exp $ */
/* $NetBSD: mount_msdos.c,v 1.16 1996/10/24 00:12:50 cgd Exp $ */
/*
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: mount_msdos.c,v 1.7 1996/12/09 13:40:55 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: mount_msdos.c,v 1.8 1996/12/16 17:11:38 deraadt Exp $";
#endif /* not lint */
#include <sys/cdefs.h>
@@ -121,8 +121,8 @@ main(argc, argv)
warnx("\"%s\" is a relative path.", dir);
if (getcwd(ndir, sizeof(ndir)) == NULL)
err(1, "getcwd");
- strncat(ndir, "/", sizeof(ndir) - strlen(ndir) - 1);
- strncat(ndir, dir, sizeof(ndir) - strlen(ndir) - 1);
+ strncat(ndir, "/", sizeof(ndir) - strlen(ndir));
+ strncat(ndir, dir, sizeof(ndir) - strlen(ndir));
dir = ndir;
warnx("using \"%s\" instead.", dir);
}
diff --git a/sbin/restore/dirs.c b/sbin/restore/dirs.c
index 10b593b3b99..be09ef7c52d 100644
--- a/sbin/restore/dirs.c
+++ b/sbin/restore/dirs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dirs.c,v 1.10 1996/12/15 18:49:24 millert Exp $ */
+/* $OpenBSD: dirs.c,v 1.11 1996/12/16 17:11:41 deraadt Exp $ */
/* $NetBSD: dirs.c,v 1.16 1995/06/19 00:20:11 cgd Exp $ */
/*
@@ -43,7 +43,7 @@
#if 0
static char sccsid[] = "@(#)dirs.c 8.5 (Berkeley) 8/31/94";
#else
-static char rcsid[] = "$OpenBSD: dirs.c,v 1.10 1996/12/15 18:49:24 millert Exp $";
+static char rcsid[] = "$OpenBSD: dirs.c,v 1.11 1996/12/16 17:11:41 deraadt Exp $";
#endif
#endif /* not lint */
@@ -272,7 +272,7 @@ treescan(pname, ino, todo)
*/
(void) strncpy(locname, pname, sizeof(locname) - 1);
locname[sizeof(locname) - 1] = '\0';
- (void) strncat(locname, "/", sizeof(locname) - strlen(locname) - 1);
+ (void) strncat(locname, "/", sizeof(locname) - strlen(locname));
namelen = strlen(locname);
rst_seekdir(dirp, itp->t_seekpt, itp->t_seekpt);
dp = rst_readdir(dirp); /* "." */
diff --git a/sbin/restore/interactive.c b/sbin/restore/interactive.c
index 12888f75821..69b6657a082 100644
--- a/sbin/restore/interactive.c
+++ b/sbin/restore/interactive.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: interactive.c,v 1.2 1996/06/23 14:32:15 deraadt Exp $ */
+/* $OpenBSD: interactive.c,v 1.3 1996/12/16 17:11:43 deraadt Exp $ */
/* $NetBSD: interactive.c,v 1.9 1995/03/18 14:59:44 cgd Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)interactive.c 8.3 (Berkeley) 9/13/94";
#else
-static char rcsid[] = "$OpenBSD: interactive.c,v 1.2 1996/06/23 14:32:15 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: interactive.c,v 1.3 1996/12/16 17:11:43 deraadt Exp $";
#endif
#endif /* not lint */
@@ -536,7 +536,8 @@ printlist(name, basename)
entries = 0;
listp = list;
(void) strncpy(locname, name, MAXPATHLEN);
- (void) strncat(locname, "/", MAXPATHLEN);
+ locname[sizeof locname - 1] = '\0';
+ (void) strncat(locname, "/", MAXPATHLEN - strlen(locname));
namelen = strlen(locname);
while (dp = rst_readdir(dirp)) {
if (dp == NULL)