Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2009-03-03 02:30:59 +0300
committerJeff Johnston <jjohnstn@redhat.com>2009-03-03 02:30:59 +0300
commit95d85fcb1ad3fc0eeffa8e6b26bee429983116e3 (patch)
tree47dc95a41106a813a4b777edf8bbe6b37191dfb7 /newlib/libc/stdlib/wctomb.c
parent49b09e5afa22995997518beca6bdb71408b0f479 (diff)
2009-03-02 Jeff Johnston <jjohnstn@redhat.com>
* libc/stdlib/wctomb_r.c (_wctomb_r): When checking single-byte charset, cast wchar to size_t in case wchar_t is signed. * libc/stdlib/wctomb.c (wctomb): Add similar single-byte check.
Diffstat (limited to 'newlib/libc/stdlib/wctomb.c')
-rw-r--r--newlib/libc/stdlib/wctomb.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/newlib/libc/stdlib/wctomb.c b/newlib/libc/stdlib/wctomb.c
index f2c62496f..2ab7b0339 100644
--- a/newlib/libc/stdlib/wctomb.c
+++ b/newlib/libc/stdlib/wctomb.c
@@ -48,6 +48,7 @@ effects vary with the locale.
#include <newlib.h>
#include <stdlib.h>
+#include <errno.h>
int
_DEFUN (wctomb, (s, wchar),
@@ -62,6 +63,12 @@ _DEFUN (wctomb, (s, wchar),
if (s == NULL)
return 0;
+ /* Verify that wchar is a valid single-byte character. */
+ if ((size_t)wchar >= 0x100) {
+ errno = EILSEQ;
+ return -1;
+ }
+
*s = (char) wchar;
return 1;
#endif /* not _MB_CAPABLE */