summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2017-02-08 04:14:26 +0000
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2017-02-08 04:14:26 +0000
commita45db08b92bac87d83890767c2216a8cbdf0a3f7 (patch)
tree773fe4ceafa797e3d0702bcaa1463a9b38f4146f
parentcaf54ef23c3d2c6bd568bc9a10e668e6982d909e (diff)
downloadgcompat-a45db08b92bac87d83890767c2216a8cbdf0a3f7.tar.gz
gcompat-a45db08b92bac87d83890767c2216a8cbdf0a3f7.tar.bz2
gcompat-a45db08b92bac87d83890767c2216a8cbdf0a3f7.tar.xz
gcompat-a45db08b92bac87d83890767c2216a8cbdf0a3f7.zip
string: Add __strcat_chk and __strncpy_chk
-rw-r--r--string.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/string.c b/string.c
index e50716a..9a1cb60 100644
--- a/string.c
+++ b/string.c
@@ -26,6 +26,22 @@ char *__strncat_chk(char *dest, const char *src, size_t n, size_t destlen)
return strncat(dest, src, n);
}
+/* "Checked" strcat */
+char *__strcat_chk(char *dest, const char *src, size_t destlen)
+{
+ return strncat(dest, src, destlen - 1);
+}
+
+/* "Checked" strncpy */
+char *__strncpy_chk(char *dest, const char *src, size_t n, size_t destlen)
+{
+ assert(dest != NULL);
+ assert(src != NULL);
+ assert(strlen(src) < destlen);
+
+ return strncpy(dest, src, n);
+}
+
/* "Checked" strcpy */
char *__strcpy_chk(char *dest, const char *src, size_t destlen)
{