diff options
author | 2014-12-11 20:39:06 +0000 | |
---|---|---|
committer | 2014-12-11 20:39:06 +0000 | |
commit | a9f9340d7fae3c9d030d61dffef1fe55d9ae44f1 (patch) | |
tree | 52a123a7c5f751fa27b011e833d0e296eceb6f0c | |
parent | The utwitch(4) driver was never added here. Obviously it belongs in the (diff) | |
download | wireguard-openbsd-a9f9340d7fae3c9d030d61dffef1fe55d9ae44f1.tar.xz wireguard-openbsd-a9f9340d7fae3c9d030d61dffef1fe55d9ae44f1.zip |
use a local swapbytes function instead of relying on undefined
overlapping swab behavior. vaguely ok kettenis
-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; |