summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-05-07 20:02:39 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-05-07 20:02:39 -0500
commitc820eed56f8e30a524050d8f91148decfea1ec9b (patch)
tree019992d2f05a68c4a863939a25c54d6356108596
parent620e2ff5197dbf6c6e1a8ca6faf532dc2e874e65 (diff)
downloadgcompat-c820eed56f8e30a524050d8f91148decfea1ec9b.tar.gz
gcompat-c820eed56f8e30a524050d8f91148decfea1ec9b.tar.bz2
gcompat-c820eed56f8e30a524050d8f91148decfea1ec9b.tar.xz
gcompat-c820eed56f8e30a524050d8f91148decfea1ec9b.zip
wchar: Add __wcscpy_chk
-rw-r--r--CHANGELOG.rst5
-rw-r--r--libgcompat/wchar.c21
2 files changed, 26 insertions, 0 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 5a17069..a4d7698 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -11,6 +11,11 @@
1.0.0 (20??-??-??)
==================
+wchar
+-----
+
+* Add __wcscpy_chk.
+
0.4.0 (2019-05-03)
==================
diff --git a/libgcompat/wchar.c b/libgcompat/wchar.c
index c60963e..1a5a23c 100644
--- a/libgcompat/wchar.c
+++ b/libgcompat/wchar.c
@@ -40,6 +40,27 @@ int __vswprintf_chk(wchar_t *s, size_t n, int flag, size_t slen,
}
/**
+ * Copy a wide-character string, with buffer overflow checking
+ *
+ * LSB 5.0: LSB-Core-generic/baselib---wcscpy-chk-1.html
+ */
+wchar_t *__wcscpy_chk(wchar_t *dest, const wchar_t *src, size_t n)
+{
+ size_t srclen = wcslen(src) + 1;
+
+ assert(dest != NULL);
+ assert(src != NULL);
+ assert(n >= srclen);
+ if (dest < src) {
+ assert(dest + n <= src);
+ } else {
+ assert(src + n <= dest);
+ }
+
+ return wcscpy(dest, src);
+}
+
+/**
* Representation of the glibc internals of wcstol(3).
*
* LSB 5.0: LSB-Core-generic/baselib---wcstol-internal-1.html