summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2003-03-13 05:00:41 +0000
committerderaadt <deraadt@openbsd.org>2003-03-13 05:00:41 +0000
commit15f407e723e61082c340d0003e02061d32604a39 (patch)
tree481602f00ad19585b85ef765b5f0d5185f1ff7a5
parentsync (diff)
downloadwireguard-openbsd-15f407e723e61082c340d0003e02061d32604a39.tar.xz
wireguard-openbsd-15f407e723e61082c340d0003e02061d32604a39.zip
more strlcpy; most from Hans-Joerg.Hoexer@yerbouti.franken.de, a bit from me
-rw-r--r--sbin/badsect/badsect.c6
-rw-r--r--sbin/restore/dirs.c6
-rw-r--r--sbin/restore/restore.c8
-rw-r--r--sbin/restore/tape.c15
-rw-r--r--sbin/restore/utilities.c8
-rw-r--r--sbin/scsi/scsi.c7
6 files changed, 24 insertions, 26 deletions
diff --git a/sbin/badsect/badsect.c b/sbin/badsect/badsect.c
index a85d45cb586..8262e54d9d5 100644
--- a/sbin/badsect/badsect.c
+++ b/sbin/badsect/badsect.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: badsect.c,v 1.9 2002/07/03 22:32:32 deraadt Exp $ */
+/* $OpenBSD: badsect.c,v 1.10 2003/03/13 05:00:41 deraadt Exp $ */
/* $NetBSD: badsect.c,v 1.10 1995/03/18 14:54:28 cgd Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)badsect.c 8.1 (Berkeley) 6/5/93";
#else
-static char rcsid[] = "$OpenBSD: badsect.c,v 1.9 2002/07/03 22:32:32 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: badsect.c,v 1.10 2003/03/13 05:00:41 deraadt Exp $";
#endif
#endif /* not lint */
@@ -110,7 +110,7 @@ main(int argc, char *argv[])
perror(argv[1]);
exit(2);
}
- strcpy(name, _PATH_DEV);
+ strlcpy(name, _PATH_DEV, sizeof name);
len = strlen(name);
if ((dirp = opendir(name)) == NULL) {
perror(name);
diff --git a/sbin/restore/dirs.c b/sbin/restore/dirs.c
index a562c9a2058..b2c01430c53 100644
--- a/sbin/restore/dirs.c
+++ b/sbin/restore/dirs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dirs.c,v 1.19 2002/02/16 21:27:37 millert Exp $ */
+/* $OpenBSD: dirs.c,v 1.20 2003/03/13 05:00:44 deraadt Exp $ */
/* $NetBSD: dirs.c,v 1.26 1997/07/01 05:37:49 lukem 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.19 2002/02/16 21:27:37 millert Exp $";
+static char rcsid[] = "$OpenBSD: dirs.c,v 1.20 2003/03/13 05:00:44 deraadt Exp $";
#endif
#endif /* not lint */
@@ -301,7 +301,7 @@ pathsearch(pathname)
struct direct *dp;
char *path, *name, buffer[MAXPATHLEN];
- strcpy(buffer, pathname);
+ strlcpy(buffer, pathname, sizeof buffer);
path = buffer;
ino = ROOTINO;
while (*path == '/')
diff --git a/sbin/restore/restore.c b/sbin/restore/restore.c
index 28afa13f237..3101d9be8b5 100644
--- a/sbin/restore/restore.c
+++ b/sbin/restore/restore.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: restore.c,v 1.8 2002/05/29 19:23:34 deraadt Exp $ */
+/* $OpenBSD: restore.c,v 1.9 2003/03/13 05:00:44 deraadt Exp $ */
/* $NetBSD: restore.c,v 1.9 1997/06/18 07:10:16 lukem Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)restore.c 8.3 (Berkeley) 9/13/94";
#else
-static char rcsid[] = "$OpenBSD: restore.c,v 1.8 2002/05/29 19:23:34 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: restore.c,v 1.9 2003/03/13 05:00:44 deraadt Exp $";
#endif
#endif /* not lint */
@@ -512,7 +512,7 @@ keyval(key)
{
static char keybuf[32];
- (void)strcpy(keybuf, "|NIL");
+ (void)strlcpy(keybuf, "|NIL", sizeof keybuf);
keybuf[0] = '\0';
if (key & ONTAPE)
(void)strlcat(keybuf, "|ONTAPE", sizeof keybuf);
@@ -797,7 +797,7 @@ createlinks()
for (np = ep->e_links; np != NULL; np = np->e_links) {
if ((np->e_flags & NEW) == 0)
continue;
- (void)strcpy(name, myname(ep));
+ (void)strlcpy(name, myname(ep), sizeof name);
if (ep->e_type == NODE) {
(void)linkit(name, myname(np), SYMLINK);
} else {
diff --git a/sbin/restore/tape.c b/sbin/restore/tape.c
index 713066bd44e..d0cb7ec5374 100644
--- a/sbin/restore/tape.c
+++ b/sbin/restore/tape.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tape.c,v 1.21 2002/02/19 19:39:38 millert Exp $ */
+/* $OpenBSD: tape.c,v 1.22 2003/03/13 05:00:44 deraadt Exp $ */
/* $NetBSD: tape.c,v 1.26 1997/04/15 07:12:25 lukem Exp $ */
/*
@@ -148,7 +148,7 @@ setinput(source)
}
pipein++;
}
- (void)strcpy(magtape, source);
+ (void)strlcpy(magtape, source, sizeof magtape);
}
void
@@ -309,11 +309,11 @@ again:
" towards the first.\n");
} else {
fprintf(stderr, "You have read volumes");
- strcpy(buf, ": ");
+ strlcpy(buf, ": ", sizeof buf);
for (i = 1; i < 32; i++)
if (tapesread & (1 << i)) {
fprintf(stderr, "%s%ld", buf, i);
- strcpy(buf, ", ");
+ strlcpy(buf, ", ", sizeof buf);
}
fprintf(stderr, "\n");
}
@@ -346,10 +346,9 @@ again:
terminateinput();
return;
}
- if (buf[0] != '\n') {
- (void)strcpy(magtape, buf);
- magtape[strlen(magtape) - 1] = '\0';
- }
+ if (buf[0] != '\n')
+ (void)strlcpy(magtape, buf, sizeof magtape);
+
#ifdef RRESTORE
if (host)
mt = rmtopen(magtape, 0);
diff --git a/sbin/restore/utilities.c b/sbin/restore/utilities.c
index 273e4ce1ad4..aacef6c27c9 100644
--- a/sbin/restore/utilities.c
+++ b/sbin/restore/utilities.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: utilities.c,v 1.10 2002/05/29 19:23:34 deraadt Exp $ */
+/* $OpenBSD: utilities.c,v 1.11 2003/03/13 05:00:44 deraadt Exp $ */
/* $NetBSD: utilities.c,v 1.11 1997/03/19 08:42:56 lukem Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)utilities.c 8.4 (Berkeley) 10/18/94";
#else
-static char rcsid[] = "$OpenBSD: utilities.c,v 1.10 2002/05/29 19:23:34 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: utilities.c,v 1.11 2003/03/13 05:00:44 deraadt Exp $";
#endif
#endif /* not lint */
@@ -99,7 +99,7 @@ mktempname(ep)
if (ep->e_flags & TMPNAME)
badentry(ep, "mktempname: called with TMPNAME");
ep->e_flags |= TMPNAME;
- (void)strcpy(oldname, myname(ep));
+ (void)strlcpy(oldname, myname(ep), sizeof oldname);
freename(ep->e_name);
ep->e_name = savename(gentempname(ep));
ep->e_namlen = strlen(ep->e_name);
@@ -345,7 +345,7 @@ flagvalues(ep)
{
static char flagbuf[BUFSIZ];
- (void)strcpy(flagbuf, "|NIL");
+ (void)strlcpy(flagbuf, "|NIL", sizeof flagbuf);
flagbuf[0] = '\0';
if (ep->e_flags & REMOVED)
(void)strlcat(flagbuf, "|REMOVED", sizeof flagbuf);
diff --git a/sbin/scsi/scsi.c b/sbin/scsi/scsi.c
index f46cccccf36..c530c0beb66 100644
--- a/sbin/scsi/scsi.c
+++ b/sbin/scsi/scsi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsi.c,v 1.9 2003/02/20 21:47:27 millert Exp $ */
+/* $OpenBSD: scsi.c,v 1.10 2003/03/13 05:00:45 deraadt Exp $ */
/* $FreeBSD: scsi.c,v 1.11 1996/04/06 11:00:28 joerg Exp $ */
/*
@@ -651,7 +651,7 @@ edit_init(void)
int fd;
edit_rewind();
- strcpy(edit_name, "/var/tmp/scXXXXXXXX");
+ strlcpy(edit_name, "/var/tmp/scXXXXXXXX", sizeof edit_name);
if ((fd = mkstemp(edit_name)) == -1) {
perror("mkstemp failed");
exit(errno);
@@ -745,8 +745,7 @@ edit_edit(void)
fclose(edit_file);
- system_line = malloc(strlen(editor) + strlen(edit_name) + 6);
- sprintf(system_line, "%s %s", editor, edit_name);
+ asprintf(&system_line, "%s %s", editor, edit_name);
system(system_line);
free(system_line);