svn commit: r328427 - head/bin/dd
Eitan Adler
eadler at FreeBSD.org
Fri Jan 26 03:30:06 UTC 2018
Author: eadler
Date: Fri Jan 26 03:30:05 2018
New Revision: 328427
URL: https://svnweb.freebsd.org/changeset/base/328427
Log:
dd(1): Use a local swapbytes() function.
swab(3) has restrict qualifiers for src and dst.
Avoid relying on undefined overlapping swab behavior.
Obtained From: OpenBSD
Modified:
head/bin/dd/dd.c
Modified: head/bin/dd/dd.c
==============================================================================
--- head/bin/dd/dd.c Fri Jan 26 00:58:32 2018 (r328426)
+++ head/bin/dd/dd.c Fri Jan 26 03:30:05 2018 (r328427)
@@ -339,6 +339,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;
@@ -438,7 +453,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;
More information about the svn-src-all
mailing list