vfs: check userland buffers before reading them.
[haiku.git] / src / system / libroot / posix / wchar / wcsspn.c
blobea799a9be358ccdb9ddbb38c09ebe25ec6a432fc
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 size_t
10 __wcsspn(const wchar_t* wcs, const wchar_t* acceptIn)
12 const wchar_t* wcPointer = wcs;
13 wchar_t wc;
14 for (; (wc = *wcPointer) != L'\0'; ++wcPointer) {
15 const wchar_t* accept;
16 for (accept = acceptIn; *accept != L'\0'; ++accept) {
17 if (*accept == wc)
18 break;
20 if (*accept == L'\0')
21 break;
24 return wcPointer - wcs;
28 B_DEFINE_WEAK_ALIAS(__wcsspn, wcsspn);