From: Waldemar Kozaczuk <jwkozac...@gmail.com>
Committer: Waldemar Kozaczuk <jwkozac...@gmail.com>
Branch: master

multibyte: add __mbstowcs_chk

Signed-off-by: Waldemar Kozaczuk <jwkozac...@gmail.com>

---
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -1451,6 +1451,7 @@ libc += multibyte/__mbsnrtowcs_chk.o
 musl += multibyte/mbsrtowcs.o
 libc += multibyte/__mbsrtowcs_chk.o
 musl += multibyte/mbstowcs.o
+libc += multibyte/__mbstowcs_chk.o
 musl += multibyte/mbtowc.o
 musl += multibyte/wcrtomb.o
 musl += multibyte/wcsnrtombs.o
diff --git a/libc/multibyte/__mbstowcs_chk.c b/libc/multibyte/__mbstowcs_chk.c
--- a/libc/multibyte/__mbstowcs_chk.c
+++ b/libc/multibyte/__mbstowcs_chk.c
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2022 Waldemar Kozaczuk
+ *
+ * This work is open source software, licensed under the terms of the
+ * BSD license as described in the LICENSE file in the top-level directory.
+ */
+
+#include <wchar.h>
+#include <libc/internal/libc.h>
+
+size_t __mbstowcs_chk(wchar_t *restrict dest, const char *restrict src, size_t 
n, size_t dstlen)
+{
+    if (n > dstlen) {
+        _chk_fail("mbstowcs");
+    }
+    return mbstowcs(dest, src, n);
+}

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/0000000000005e29fd05dfffc60e%40google.com.

Reply via email to