aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorEitan Adler <eadler@FreeBSD.org>2018-03-17 03:00:24 +0000
committerEitan Adler <eadler@FreeBSD.org>2018-03-17 03:00:24 +0000
commit1e6f0e83f4447d80a59c9b9c73822cfd83371a18 (patch)
treedb3d13292a6108d1b64c43c9d1a695229f263134 /bin
parent685b13aa35299ea3dd041256dae025ffbe17a2e2 (diff)
Notes
Diffstat (limited to 'bin')
-rw-r--r--bin/dd/dd.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/bin/dd/dd.c b/bin/dd/dd.c
index cab621fe4ded..90ac2415ad54 100644
--- a/bin/dd/dd.c
+++ b/bin/dd/dd.c
@@ -303,6 +303,21 @@ speed_limit(void)
}
static void
+swapbytes(void *v, size_t len)
+{
+ unsigned char *p = v;
+ unsigned char t;
+
+ while (len > 1) {
+ t = p[0];
+ p[0] = p[1];
+ p[1] = t;
+ p += 2;
+ len -= 2;
+ }
+}
+
+static void
dd_in(void)
{
ssize_t n;
@@ -402,7 +417,7 @@ dd_in(void)
++st.swab;
--n;
}
- swab(in.dbp, in.dbp, (size_t)n);
+ swapbytes(in.dbp, (size_t)n);
}
in.dbp += in.dbrcnt;