aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncaen <mail@duncano.de>2018-11-09 11:40:21 +0100
committerDuncaen <mail@duncano.de>2018-11-09 11:40:21 +0100
commitb07a16375075850146cac15e8cf3e388375bf47d (patch)
tree5c4fc90892c422cc5505203e926ba4d0a8bfb124
parent8ea9c32a276d2b17431a8aee08ba546152d89441 (diff)
downloadlobase-b07a16375075850146cac15e8cf3e388375bf47d.tar.gz
bin/dd: update to OPENBSD_6_4HEADmaster
-rw-r--r--bin/dd/args.c17
-rw-r--r--bin/dd/dd.c14
-rw-r--r--bin/dd/misc.c38
3 files changed, 27 insertions, 42 deletions
diff --git a/bin/dd/args.c b/bin/dd/args.c
index 6cd6de9..033179d 100644
--- a/bin/dd/args.c
+++ b/bin/dd/args.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: args.c,v 1.29 2018/01/03 19:12:20 schwarze Exp $ */
+/* $OpenBSD: args.c,v 1.30 2018/07/25 15:09:48 cheloha Exp $ */
/* $NetBSD: args.c,v 1.7 1996/03/01 01:18:58 jtc Exp $ */
/*-
@@ -95,9 +95,9 @@ jcl(char **argv)
in.dbsz = out.dbsz = 512;
- while ((oper = *++argv) != NULL) {
- if ((oper = strdup(oper)) == NULL)
- errx(1, "out of memory");
+ while (*++argv != NULL) {
+ if ((oper = strdup(*argv)) == NULL)
+ err(1, NULL);
if ((arg = strchr(oper, '=')) == NULL)
errx(1, "unknown operand %s", oper);
*arg++ = '\0';
@@ -113,6 +113,7 @@ jcl(char **argv)
tmp.name);
ddflags |= ap->set;
ap->f(arg);
+ free(oper);
}
/* Final sanity checks. */
@@ -218,8 +219,8 @@ f_ibs(char *arg)
static void
f_if(char *arg)
{
-
- in.name = arg;
+ if ((in.name = strdup(arg)) == NULL)
+ err(1, NULL);
}
static void
@@ -233,8 +234,8 @@ f_obs(char *arg)
static void
f_of(char *arg)
{
-
- out.name = arg;
+ if ((out.name = strdup(arg)) == NULL)
+ err(1, NULL);
}
static void
diff --git a/bin/dd/dd.c b/bin/dd/dd.c
index 18b1cef..cc41ccf 100644
--- a/bin/dd/dd.c
+++ b/bin/dd/dd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dd.c,v 1.24 2017/08/13 02:06:42 tedu Exp $ */
+/* $OpenBSD: dd.c,v 1.25 2018/07/23 23:09:37 cheloha Exp $ */
/* $NetBSD: dd.c,v 1.6 1996/02/20 19:29:06 jtc Exp $ */
/*-
@@ -141,10 +141,14 @@ setup(void)
if ((in.db = malloc(out.dbsz + in.dbsz - 1)) == NULL)
err(1, "input buffer");
out.db = in.db;
- } else if ((in.db =
- malloc((u_int)(MAXIMUM(in.dbsz, cbsz) + cbsz))) == NULL ||
- (out.db = malloc((u_int)(out.dbsz + cbsz))) == NULL)
- err(1, "output buffer");
+ } else {
+ in.db = malloc(MAXIMUM(in.dbsz, cbsz) + cbsz);
+ if (in.db == NULL)
+ err(1, "input buffer");
+ out.db = malloc(out.dbsz + cbsz);
+ if (out.db == NULL)
+ err(1, "output buffer");
+ }
in.dbp = in.db;
out.dbp = out.db;
diff --git a/bin/dd/misc.c b/bin/dd/misc.c
index 8153971..a0c2019 100644
--- a/bin/dd/misc.c
+++ b/bin/dd/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.22 2017/10/24 14:21:10 schwarze Exp $ */
+/* $OpenBSD: misc.c,v 1.23 2018/04/07 18:52:39 cheloha Exp $ */
/* $NetBSD: misc.c,v 1.4 1995/03/21 09:04:10 cgd Exp $ */
/*-
@@ -36,13 +36,9 @@
#include <sys/types.h>
#include <sys/time.h>
-#include <sys/uio.h>
-#include <err.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <errno.h>
+#include <stdio.h>
#include <time.h>
#include <unistd.h>
@@ -53,10 +49,7 @@ void
summary(void)
{
struct timespec elapsed, now;
- char buf[4][100];
- struct iovec iov[4];
double nanosecs;
- int i = 0;
if (ddflags & C_NOINFO)
return;
@@ -67,38 +60,25 @@ summary(void)
if (nanosecs == 0)
nanosecs = 1;
- /* Use snprintf(3) so that we don't reenter stdio(3). */
- (void)snprintf(buf[0], sizeof(buf[0]),
- "%zu+%zu records in\n%zu+%zu records out\n",
+ /* Be async safe: use dprintf(3). */
+ dprintf(STDERR_FILENO, "%zu+%zu records in\n%zu+%zu records out\n",
st.in_full, st.in_part, st.out_full, st.out_part);
- iov[i].iov_base = buf[0];
- iov[i++].iov_len = strlen(buf[0]);
if (st.swab) {
- (void)snprintf(buf[1], sizeof(buf[1]),
- "%zu odd length swab %s\n",
- st.swab, (st.swab == 1) ? "block" : "blocks");
- iov[i].iov_base = buf[1];
- iov[i++].iov_len = strlen(buf[1]);
+ dprintf(STDERR_FILENO, "%zu odd length swab %s\n",
+ st.swab, (st.swab == 1) ? "block" : "blocks");
}
if (st.trunc) {
- (void)snprintf(buf[2], sizeof(buf[2]),
- "%zu truncated %s\n",
- st.trunc, (st.trunc == 1) ? "block" : "blocks");
- iov[i].iov_base = buf[2];
- iov[i++].iov_len = strlen(buf[2]);
+ dprintf(STDERR_FILENO, "%zu truncated %s\n",
+ st.trunc, (st.trunc == 1) ? "block" : "blocks");
}
if (!(ddflags & C_NOXFER)) {
- (void)snprintf(buf[3], sizeof(buf[3]),
+ dprintf(STDERR_FILENO,
"%lld bytes transferred in %lld.%03ld secs "
"(%0.0f bytes/sec)\n", (long long)st.bytes,
(long long)elapsed.tv_sec, elapsed.tv_nsec / 1000000,
((double)st.bytes * 1000000000) / nanosecs);
- iov[i].iov_base = buf[3];
- iov[i++].iov_len = strlen(buf[3]);
}
-
- (void)writev(STDERR_FILENO, iov, i);
}
void