vfs: check userland buffers before reading them.
[haiku.git] / src / system / libroot / posix / wchar / wcsncmp.c
blob185de9630f4271380c818656c4aa0aef661d7286
1 /*
2 ** Copyright 2011, Oliver Tappe, zooey@hirschkaefer.de. All rights reserved.
3 ** Distributed under the terms of the Haiku License.
4 */
6 #include <wchar_private.h>
9 int
10 __wcsncmp(const wchar_t* wcs1, const wchar_t* wcs2, size_t count)
12 int cmp = 0;
14 while (count-- > 0) {
15 cmp = *wcs1 - *wcs2++;
16 /* note: won't overflow, since our wchar_t is guaranteed to never
17 have the highest bit set */
19 if (cmp != 0 || *wcs1++ == L'\0')
20 break;
23 return cmp;
27 B_DEFINE_WEAK_ALIAS(__wcsncmp, wcsncmp);