diff options
author | Rich Felker <dalias@aerifal.cx> | 2014-10-04 11:14:01 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2014-10-04 11:14:01 -0400 |
commit | dccbf4c809efc311aa37da71de70d04dfd8b0db3 (patch) | |
tree | e2651ba2140ab3d6b0a3b07e2d5f75df29cccfbb | |
parent | 05cef96d9e63a00b319f88343cf9869c8e612843 (diff) | |
download | musl-dccbf4c809efc311aa37da71de70d04dfd8b0db3.tar.gz musl-dccbf4c809efc311aa37da71de70d04dfd8b0db3.tar.bz2 musl-dccbf4c809efc311aa37da71de70d04dfd8b0db3.tar.xz musl-dccbf4c809efc311aa37da71de70d04dfd8b0db3.zip |
fix handling of odd lengths in swab function
this function is specified to leave the last byte with "unspecified
disposition" when the length is odd, so for the most part correct
programs should not be calling swab with odd lengths. however, doing
so is permitted, and should not write past the end of the destination
buffer.
-rw-r--r-- | src/string/swab.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/string/swab.c b/src/string/swab.c index 9ed6fcda..ace0f466 100644 --- a/src/string/swab.c +++ b/src/string/swab.c @@ -4,7 +4,7 @@ void swab(const void *restrict _src, void *restrict _dest, ssize_t n) { const char *src = _src; char *dest = _dest; - for (; n>0; n-=2) { + for (; n>1; n-=2) { dest[0] = src[1]; dest[1] = src[0]; dest += 2; |