summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2002-10-16 11:37:38 +0000
committertjr <tjr@FreeBSD.org>2002-10-16 11:37:38 +0000
commitccd9275d4ea58567606a870a1c0faabbbabd889b (patch)
tree26381dc2c8f2afcccd8979d711a33ab0f820c273 /lib/libc
parent1ff9dd778b578b4c35ac8c79b4d8289b24b4653b (diff)
downloadFreeBSD-src-ccd9275d4ea58567606a870a1c0faabbbabd889b.zip
FreeBSD-src-ccd9275d4ea58567606a870a1c0faabbbabd889b.tar.gz
Avoid truncating invalid wide characters that are outside the range of
'unsigned char'; signal an error instead.
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/locale/none.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/libc/locale/none.c b/lib/libc/locale/none.c
index f062f90..1b1dc70 100644
--- a/lib/libc/locale/none.c
+++ b/lib/libc/locale/none.c
@@ -40,6 +40,7 @@ static char sccsid[] = "@(#)none.c 8.1 (Berkeley) 6/4/93";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <limits.h>
#include <stddef.h>
#include <stdio.h>
#include <rune.h>
@@ -82,8 +83,14 @@ _none_sputrune(c, string, n, result)
size_t n;
{
if (n >= 1) {
- if (string)
+ if (string) {
+ if (c < 0 || c > UCHAR_MAX) {
+ if (result)
+ *result = NULL;
+ return (0);
+ }
*string = c;
+ }
if (result)
*result = string + 1;
} else if (result)
OpenPOWER on IntegriCloud