diff options
author | eadler <eadler@FreeBSD.org> | 2018-01-26 03:30:05 +0000 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-08-20 14:03:20 +0200 |
commit | 208ebf209906482b7a18adf11c186263d7db3b7c (patch) | |
tree | 398d94b9ddfa9abe734c13839136410408c8f29a /cpukit/libmisc/shell/main_dd.c | |
parent | spintrcritical23: Fix unused variable warnings (diff) | |
download | rtems-208ebf209906482b7a18adf11c186263d7db3b7c.tar.bz2 |
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
Diffstat (limited to '')
-rw-r--r-- | cpukit/libmisc/shell/main_dd.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/cpukit/libmisc/shell/main_dd.c b/cpukit/libmisc/shell/main_dd.c index 1a715303ef..35cd826711 100644 --- a/cpukit/libmisc/shell/main_dd.c +++ b/cpukit/libmisc/shell/main_dd.c @@ -335,6 +335,21 @@ getfdtype(rtems_shell_dd_globals* globals, 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(rtems_shell_dd_globals* globals) { ssize_t n; @@ -431,7 +446,7 @@ dd_in(rtems_shell_dd_globals* globals) ++st.swab; --n; } - swab(in.dbp, in.dbp, (size_t)n); + swapbytes(in.dbp, (size_t)n); } in.dbp += in.dbrcnt; |