summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2003-04-04 22:12:08 +0000
committerderaadt <deraadt@openbsd.org>2003-04-04 22:12:08 +0000
commit500685807b8eb4a0c2eff90c8fc95b416d73459a (patch)
tree4e482da6ee1138b4fe38a43cd10062be849a44d3
parenteasy snprintf; tedu ok (diff)
downloadwireguard-openbsd-500685807b8eb4a0c2eff90c8fc95b416d73459a.tar.xz
wireguard-openbsd-500685807b8eb4a0c2eff90c8fc95b416d73459a.zip
simple snprintf; tdeval matthieu ok
-rw-r--r--usr.bin/ar/ar.c11
-rw-r--r--usr.bin/ar/archive.c13
-rw-r--r--usr.bin/ranlib/build.c6
-rw-r--r--usr.bin/ranlib/touch.c7
4 files changed, 22 insertions, 15 deletions
diff --git a/usr.bin/ar/ar.c b/usr.bin/ar/ar.c
index 090d17cf2c3..e640c8f301c 100644
--- a/usr.bin/ar/ar.c
+++ b/usr.bin/ar/ar.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ar.c,v 1.8 2002/12/11 22:01:13 millert Exp $ */
+/* $OpenBSD: ar.c,v 1.9 2003/04/04 22:12:08 deraadt Exp $ */
/* $NetBSD: ar.c,v 1.5 1995/03/26 03:27:44 glass Exp $ */
/*-
@@ -47,7 +47,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)ar.c 8.3 (Berkeley) 4/2/94";
#else
-static char rcsid[] = "$OpenBSD: ar.c,v 1.8 2002/12/11 22:01:13 millert Exp $";
+static char rcsid[] = "$OpenBSD: ar.c,v 1.9 2003/04/04 22:12:08 deraadt Exp $";
#endif
#endif /* not lint */
@@ -94,10 +94,13 @@ main(argc, argv)
* Fix it, if necessary.
*/
if (*argv[1] != '-') {
- if (!(p = malloc((u_int)(strlen(argv[1]) + 2))))
+ size_t len;
+
+ len = (u_int)(strlen(argv[1]) + 2);
+ if (!(p = malloc(len)))
err(1, NULL);
*p = '-';
- (void)strcpy(p + 1, argv[1]); /* ok */
+ (void)strlcpy(p + 1, argv[1], len - 1);
argv[1] = p;
}
diff --git a/usr.bin/ar/archive.c b/usr.bin/ar/archive.c
index 9aeda12f0ca..6043df2f074 100644
--- a/usr.bin/ar/archive.c
+++ b/usr.bin/ar/archive.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: archive.c,v 1.7 2002/12/14 18:14:35 millert Exp $ */
+/* $OpenBSD: archive.c,v 1.8 2003/04/04 22:12:09 deraadt Exp $ */
/* $NetBSD: archive.c,v 1.7 1995/03/26 03:27:46 glass Exp $ */
/*-
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)archive.c 8.3 (Berkeley) 4/2/94";
#else
-static char rcsid[] = "$OpenBSD: archive.c,v 1.7 2002/12/14 18:14:35 millert Exp $";
+static char rcsid[] = "$OpenBSD: archive.c,v 1.8 2003/04/04 22:12:09 deraadt Exp $";
#endif
#endif /* not lint */
@@ -246,16 +246,19 @@ put_arobj(cfp, sb)
name, OLDARMAXNAME, name);
(void)fflush(stderr);
}
- (void)sprintf(hb, HDR3, name, (long int)sb->st_mtimespec.tv_sec,
+ (void)snprintf(hb, sizeof hb,
+ HDR3, name, (long int)sb->st_mtimespec.tv_sec,
uid, gid, sb->st_mode, sb->st_size, ARFMAG);
lname = 0;
} else if (lname > sizeof(hdr->ar_name) || strchr(name, ' '))
- (void)sprintf(hb, HDR1, AR_EFMT1, lname,
+ (void)snprintf(hb, sizeof hb,
+ HDR1, AR_EFMT1, lname,
(long int)sb->st_mtimespec.tv_sec, uid, gid, sb->st_mode,
sb->st_size + lname, ARFMAG);
else {
lname = 0;
- (void)sprintf(hb, HDR2, name, (long int)sb->st_mtimespec.tv_sec,
+ (void)snprintf(hb, sizeof hb,
+ HDR2, name, (long int)sb->st_mtimespec.tv_sec,
uid, gid, sb->st_mode, sb->st_size, ARFMAG);
}
size = sb->st_size;
diff --git a/usr.bin/ranlib/build.c b/usr.bin/ranlib/build.c
index 9fb7fa41235..51a942e292a 100644
--- a/usr.bin/ranlib/build.c
+++ b/usr.bin/ranlib/build.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: build.c,v 1.8 2001/11/19 19:02:15 mpech Exp $ */
+/* $OpenBSD: build.c,v 1.9 2003/04/04 22:12:09 deraadt Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -38,7 +38,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)build.c 5.3 (Berkeley) 3/12/91";*/
-static char rcsid[] = "$OpenBSD: build.c,v 1.8 2001/11/19 19:02:15 mpech Exp $";
+static char rcsid[] = "$OpenBSD: build.c,v 1.9 2003/04/04 22:12:09 deraadt Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -284,7 +284,7 @@ symobj(mid)
/* Put out the ranlib archive file header. */
#define DEFMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
- (void)sprintf(hb, HDR2, RANLIBMAG, 0L, uid, gid,
+ (void)snprintf(hb, sizeof hb, HDR2, RANLIBMAG, 0L, uid, gid,
DEFMODE & ~umask(0), (off_t)ransize, ARFMAG);
if (!fwrite(hb, sizeof(struct ar_hdr), 1, fp))
error(tname);
diff --git a/usr.bin/ranlib/touch.c b/usr.bin/ranlib/touch.c
index 9841039207c..eb181229778 100644
--- a/usr.bin/ranlib/touch.c
+++ b/usr.bin/ranlib/touch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: touch.c,v 1.3 1999/09/21 13:15:43 espie Exp $ */
+/* $OpenBSD: touch.c,v 1.4 2003/04/04 22:12:09 deraadt Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -38,7 +38,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)touch.c 5.3 (Berkeley) 3/12/91";*/
-static char rcsid[] = "$OpenBSD: touch.c,v 1.3 1999/09/21 13:15:43 espie Exp $";
+static char rcsid[] = "$OpenBSD: touch.c,v 1.4 2003/04/04 22:12:09 deraadt Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -84,7 +84,8 @@ settime(afd)
size = SARMAG + sizeof(hdr->ar_name);
if (lseek(afd, size, SEEK_SET) == (off_t)-1)
error(archive);
- (void)sprintf(buf, "%-12ld", (long int)time((time_t *)NULL) + RANLIBSKEW);
+ (void)snprintf(buf, sizeof buf,
+ "%-12ld", (long int)time((time_t *)NULL) + RANLIBSKEW);
if (write(afd, buf, sizeof(hdr->ar_date)) != sizeof(hdr->ar_date))
error(archive);
}