summaryrefslogtreecommitdiffstats
path: root/lib/libc/string/swab.c
diff options
context:
space:
mode:
authoreadler <eadler@FreeBSD.org>2012-03-04 16:39:08 +0000
committereadler <eadler@FreeBSD.org>2012-03-04 16:39:08 +0000
commit47d5c92c94b33a3eb80d6efa5f6e811af803179c (patch)
tree866b9ecf086f1897f52a6808bdbf7e84a625cea3 /lib/libc/string/swab.c
parent2c21c36313d7c9853eaca967a13499c5db0100aa (diff)
downloadFreeBSD-src-47d5c92c94b33a3eb80d6efa5f6e811af803179c.zip
FreeBSD-src-47d5c92c94b33a3eb80d6efa5f6e811af803179c.tar.gz
POSIX mandates that swab do nothing when len < 0
PR: kern/140690 Submitted by: Jeremy Huddleston <jeremyhu@apple.com> Approved by: cperciva MFC after: 2 weeks
Diffstat (limited to 'lib/libc/string/swab.c')
-rw-r--r--lib/libc/string/swab.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/libc/string/swab.c b/lib/libc/string/swab.c
index 1db7d1f..ec6cbf0 100644
--- a/lib/libc/string/swab.c
+++ b/lib/libc/string/swab.c
@@ -45,6 +45,8 @@ swab(const void * __restrict from, void * __restrict to, ssize_t len)
int n;
char *fp, *tp;
+ if (len <= 0)
+ return;
n = len >> 1;
fp = (char *)from;
tp = (char *)to;
OpenPOWER on IntegriCloud