diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2017-02-08 04:14:26 +0000 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2017-02-08 04:14:26 +0000 |
commit | a45db08b92bac87d83890767c2216a8cbdf0a3f7 (patch) | |
tree | 773fe4ceafa797e3d0702bcaa1463a9b38f4146f | |
parent | caf54ef23c3d2c6bd568bc9a10e668e6982d909e (diff) | |
download | gcompat-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.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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) { |