aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/locale
diff options
context:
space:
mode:
authorTim J. Robbins <tjr@FreeBSD.org>2004-05-25 10:45:24 +0000
committerTim J. Robbins <tjr@FreeBSD.org>2004-05-25 10:45:24 +0000
commit18b20312986af58ed39c318788680fabfad739f3 (patch)
treeb8b7cf8712edde2ee4e0325226392b8964795c85 /lib/libc/locale
parentb495040835dd2b260b1300ddae6091b143751b91 (diff)
downloadsrc-18b20312986af58ed39c318788680fabfad739f3.tar.gz
src-18b20312986af58ed39c318788680fabfad739f3.zip
Scan the source string for invalid wide characters in wcsrtombs()
in the dst == NULL case.
Notes
Notes: svn path=/head/; revision=129707
Diffstat (limited to 'lib/libc/locale')
-rw-r--r--lib/libc/locale/none.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/libc/locale/none.c b/lib/libc/locale/none.c
index 6ac9a9e2712a..2a3ada6b3ee6 100644
--- a/lib/libc/locale/none.c
+++ b/lib/libc/locale/none.c
@@ -148,8 +148,15 @@ _none_wcsrtombs(char * __restrict dst, const wchar_t ** __restrict src,
const wchar_t *s;
size_t nchr;
- if (dst == NULL)
- return (wcslen(*src));
+ if (dst == NULL) {
+ for (s = *src; *s != L'\0'; s++) {
+ if (*s < 0 || *s > UCHAR_MAX) {
+ errno = EILSEQ;
+ return ((size_t)-1);
+ }
+ }
+ return (s - *src);
+ }
s = *src;
nchr = 0;