diff options
Diffstat (limited to 'bin/dd')
-rw-r--r-- | bin/dd/dd.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/bin/dd/dd.c b/bin/dd/dd.c index 423efc320d5..6be77e185d9 100644 --- a/bin/dd/dd.c +++ b/bin/dd/dd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dd.c,v 1.18 2013/06/01 16:46:49 tedu Exp $ */ +/* $OpenBSD: dd.c,v 1.19 2014/12/11 20:39:06 tedu Exp $ */ /* $NetBSD: dd.c,v 1.6 1996/02/20 19:29:06 jtc Exp $ */ /*- @@ -206,6 +206,22 @@ getfdtype(IO *io) } 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; @@ -292,7 +308,7 @@ dd_in(void) ++st.swab; --n; } - swab(in.dbp, in.dbp, n); + swapbytes(in.dbp, n); } in.dbp += in.dbrcnt; |