From f10737a4ee4a818acdc28fa2e32c85a74f47eb5c Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Wed, 31 Jan 2024 00:00:11 -0500 Subject: update to 1:1 checked functions --- src/string/memccpy.c | 2 ++ src/string/memchr.c | 2 ++ src/string/memcmp.c | 2 ++ src/string/memcpy.c | 2 ++ src/string/memcpy_s.c | 2 ++ src/string/memmove.c | 2 ++ src/string/memmove_s.c | 2 ++ src/string/memset.c | 2 ++ src/string/memset_s.c | 2 ++ src/string/strcat.c | 2 ++ src/string/strcat_s.c | 2 ++ src/string/strchr.c | 2 ++ src/string/strcmp.c | 2 ++ src/string/strcoll.c | 2 ++ src/string/strcpy.c | 2 ++ src/string/strcpy_s.c | 2 ++ src/string/strcspn.c | 2 ++ src/string/strdup.c | 3 ++- src/string/strerror.c | 3 ++- src/string/strerror_s.c | 2 ++ src/string/strerrorlen_s.c | 2 ++ src/string/strlen.c | 2 ++ src/string/strncat.c | 3 ++- src/string/strncat_s.c | 2 ++ src/string/strncmp.c | 2 ++ src/string/strncpy.c | 2 ++ src/string/strncpy_s.c | 2 ++ src/string/strnlen_s.c | 2 ++ src/string/strpbrk.c | 2 ++ src/string/strrchr.c | 3 ++- src/string/strspn.c | 2 ++ src/string/strstr.c | 2 ++ src/string/strtok.c | 2 ++ src/string/strtok_s.c | 5 +++-- src/string/strxfrm.c | 2 ++ 35 files changed, 71 insertions(+), 6 deletions(-) diff --git a/src/string/memccpy.c b/src/string/memccpy.c index 17ee0c4b..c722ba7d 100644 --- a/src/string/memccpy.c +++ b/src/string/memccpy.c @@ -21,6 +21,8 @@ void *memccpy(void * restrict s1, const void * restrict s2, int c, size_t n) return NULL; } +__check_4(void *, 0, memccpy, void * restrict, const void * restrict, int, size_t) + /* XOPEN(4) */ diff --git a/src/string/memchr.c b/src/string/memchr.c index 49965560..1c228220 100644 --- a/src/string/memchr.c +++ b/src/string/memchr.c @@ -25,6 +25,8 @@ void * memchr(const void *s, int c, size_t n) return NULL; } +__check_3(void *, 0, memchr, const void *, int, size_t) + /*** searches the first ARGUMENT(n) bytes of memory at ARGUMENT(s) for ARGUMENT(c) (converted to an TYPE(unsigned char)). diff --git a/src/string/memcmp.c b/src/string/memcmp.c index ddf57089..028d2354 100644 --- a/src/string/memcmp.c +++ b/src/string/memcmp.c @@ -27,6 +27,8 @@ int memcmp(const void *s1, const void *s2, size_t n) return 0; } +__check_3(int, 0, memcmp, const void *, const void *, size_t) + /*** compares the first ARGUMENT(n) bytes of memory at ARGUMENT(s1) and ARGUMENT(s2). diff --git a/src/string/memcpy.c b/src/string/memcpy.c index cbcb0a75..0fb76f99 100644 --- a/src/string/memcpy.c +++ b/src/string/memcpy.c @@ -24,6 +24,8 @@ void * memcpy(void * restrict s1, const void * restrict s2, size_t n) return dst; } +CHECK_3(void *, 0, memcpy, void * restrict, const void * restrict, size_t) + /*** copies ARGUMENT(n) bytes from the object at ARGUMENT(s2) to the object at ARGUMENT(s1). diff --git a/src/string/memcpy_s.c b/src/string/memcpy_s.c index 07211c4c..dc4179ea 100644 --- a/src/string/memcpy_s.c +++ b/src/string/memcpy_s.c @@ -18,6 +18,8 @@ errno_t memcpy_s(void * restrict s1, rsize_t s1max, const void * restrict s2, rs return 0; } +__check_4(errno_t, 0, memcpy_s, void * restrict, rsize_t, const void * restrict, rsize_t) + /*** The fn(memcpy) copies arg(n) bytes from the object at arg(s2) to the object at arg(s1). diff --git a/src/string/memmove.c b/src/string/memmove.c index 0ae3d309..0de82247 100644 --- a/src/string/memmove.c +++ b/src/string/memmove.c @@ -27,6 +27,8 @@ void * memmove(void *s1, const void *s2, size_t n) return s1; } +__check_3(void *, 0, memmove, void *, const void *, size_t) + /*** copies ARGUMENT(n) bytes of memory from the object at ARGUMENT(s2) to the object at ARGUMENT(s1). If ARGUMENT(s1) and ARGUMENT(s2) overlap, the memory diff --git a/src/string/memmove_s.c b/src/string/memmove_s.c index 3dea9080..0475ee00 100644 --- a/src/string/memmove_s.c +++ b/src/string/memmove_s.c @@ -17,6 +17,8 @@ errno_t memmove_s(void *s1, rsize_t s1max, const void *s2, rsize_t n) return 0; } +__check_4(errno_t, 0, memmove_s, void *, rsize_t, const void *, rsize_t) + /*** The fn(memmove) function copies arg(n) bytes of memory from the object at arg(s2) to the object at arg(s1). If arg(s1) and arg(s2) overlap, the memory diff --git a/src/string/memset.c b/src/string/memset.c index 68fbca0a..a009ec94 100644 --- a/src/string/memset.c +++ b/src/string/memset.c @@ -21,6 +21,8 @@ void * memset(void *s, int c, size_t n) return s; } +__check_3(void *, 0, memset, void *, int, size_t) + /*** fills the first ARGUMENT(n) bytes of memory at ARGUMENT(s) with the value ARGUMENT(c) (converted to an TYPE(unsigned char)). diff --git a/src/string/memset_s.c b/src/string/memset_s.c index 0708f338..f79c3e54 100644 --- a/src/string/memset_s.c +++ b/src/string/memset_s.c @@ -17,6 +17,8 @@ errno_t memset_s(void *s, rsize_t smax, int c, rsize_t n) return 0; } +__check_4(errno_t, 0, memset_s, void *, rsize_t, int, rsize_t) + /*** The fn(memset) function fills the first arg(n) bytes of memory at arg(s) with the value arg(c) (converted to an type(unsigned char)). diff --git a/src/string/strcat.c b/src/string/strcat.c index 3855cff3..547eac3e 100644 --- a/src/string/strcat.c +++ b/src/string/strcat.c @@ -22,6 +22,8 @@ char * strcat(char * restrict s1, const char * restrict s2) return s1; } +__check_2(char *, 0, strcat, char * restrict, const char * restrict) + /*** appends a copy of the string at ARGUMENT(s2) to the end of the string at ARGUMENT(s1). The first byte of ARGUMENT(s2) will overwrite the terminating diff --git a/src/string/strcat_s.c b/src/string/strcat_s.c index 40c474df..45cfefd4 100644 --- a/src/string/strcat_s.c +++ b/src/string/strcat_s.c @@ -12,6 +12,8 @@ errno_t strcat_s(char * restrict s1, rsize_t s1max, const char * restrict s2) return 0; } +__check_3(errno_t, 0, strcat_s, char * restrict, rsize_t, const char * restrict) + /*** The fn(strcat) function appends a copy of the string at arg(s2) to the end of the string at arg(s1). The first byte of arg(s2) will overwrite the terminating diff --git a/src/string/strchr.c b/src/string/strchr.c index f71c674a..5793743b 100644 --- a/src/string/strchr.c +++ b/src/string/strchr.c @@ -16,6 +16,8 @@ char * strchr(const char *s, int c) return (char*)memchr(s, (char)c, strlen(s)); } +__check_2(char *, 0, strchr, const char *, int) + /*** searches the string ARGUMENT(s) for the first occurrence of ARGUMENT(c) (converted to a TYPE(char)). diff --git a/src/string/strcmp.c b/src/string/strcmp.c index b69debc0..8c679f4b 100644 --- a/src/string/strcmp.c +++ b/src/string/strcmp.c @@ -34,6 +34,8 @@ int strcmp(const char *s1, const char *s2) return 0; } +__check_2(int, 0, strcmp, const char *, const char *) + /*** compares the strings at ARGUMENT(s1) and ARGUMENT(s2). ***/ diff --git a/src/string/strcoll.c b/src/string/strcoll.c index f70872b7..aab2f1f5 100644 --- a/src/string/strcoll.c +++ b/src/string/strcoll.c @@ -34,6 +34,8 @@ int strcoll(const char *s1, const char *s2) return ret; } +__check_2(int, 0, strcoll, const char *, const char *) + /*** compares the collation values of the strings at ARGUMENT(s1) and ARGUMENT(s2). ***/ diff --git a/src/string/strcpy.c b/src/string/strcpy.c index 1f80e41b..aa567374 100644 --- a/src/string/strcpy.c +++ b/src/string/strcpy.c @@ -23,6 +23,8 @@ char * strcpy(char * restrict s1, const char * restrict s2) return p; } +__check_2(char *, 0, strcpy, char * restrict, const char * restrict) + /*** copies the string at ARGUMENT(s2) to ARGUMENT(s1), up to and including the terminating CHAR(\0). diff --git a/src/string/strcpy_s.c b/src/string/strcpy_s.c index 4fdcc2d4..89914f23 100644 --- a/src/string/strcpy_s.c +++ b/src/string/strcpy_s.c @@ -14,6 +14,8 @@ errno_t strcpy_s(char * restrict s1, rsize_t s1max, const char * restrict s2) return 0; } +__check_3(errno_t, 0, strcpy_s, char * restrict, rsize_t, const char * restrict) + /*** The fn(strcpy) function copies the string at arg(s2) to arg(s1), up to and including the terminating char(\0). diff --git a/src/string/strcspn.c b/src/string/strcspn.c index 3438de74..19f83fda 100644 --- a/src/string/strcspn.c +++ b/src/string/strcspn.c @@ -20,6 +20,8 @@ size_t strcspn(const char *s1, const char *s2) return i; } +__check_2(size_t, 0, strcspn, const char *, const char *) + /*** the number of characters that the beginning of the string ARGUMENT(s1) that are not in the string ARGUMENT(s2). diff --git a/src/string/strdup.c b/src/string/strdup.c index 26362e2f..ecd671db 100644 --- a/src/string/strdup.c +++ b/src/string/strdup.c @@ -1,7 +1,6 @@ #include #include #include "_safety.h" -#undef strdup char * strdup(const char *s) { @@ -15,6 +14,8 @@ char * strdup(const char *s) return ret; } +__check_1(char *, 0, strdup, const char *) + /* XOPEN(400) POSIX(200809) diff --git a/src/string/strerror.c b/src/string/strerror.c index 29742e34..910d7490 100644 --- a/src/string/strerror.c +++ b/src/string/strerror.c @@ -2,7 +2,6 @@ #include #include #include "_safety.h" -#undef strerror # define __LONGEST_STRERR 64 /* FIXME */ @@ -27,6 +26,8 @@ char * strerror(int errnum) return errstr; } +__check_1(char *, 0, strerror, int) + /*** converts the error number ARGUMENT(errnum) to an error message string. The string returned should not be modified, and may be overwritten by diff --git a/src/string/strerror_s.c b/src/string/strerror_s.c index c78b0bba..65ff77c4 100644 --- a/src/string/strerror_s.c +++ b/src/string/strerror_s.c @@ -10,6 +10,8 @@ errno_t strerror_s(char *s, rsize_t maxsize, errno_t errnum) return errnum; } +__check_3(errno_t, 0, strerror_s, char *, rsize_t, errno_t) + /*** The fn(strerror_s) converts the error number arg(errnum) to an error message string. The string returned should not be modified, and may be overwritten by diff --git a/src/string/strerrorlen_s.c b/src/string/strerrorlen_s.c index c3ed5666..5e0240da 100644 --- a/src/string/strerrorlen_s.c +++ b/src/string/strerrorlen_s.c @@ -9,6 +9,8 @@ size_t strerrorlen_s(errno_t errnum) return strlen(buffer); } +__check_1(size_t, 0, strerrorlen_s, errno_t) + /* CEXT1(201112) */ diff --git a/src/string/strlen.c b/src/string/strlen.c index 44210c7c..1499eac4 100644 --- a/src/string/strlen.c +++ b/src/string/strlen.c @@ -16,6 +16,8 @@ size_t strlen(const char *s) return i; } +__check_1(size_t, 0, strlen, const char *) + /*** counts the number of bytes in the string ARGUMENT(s), not including the terminating null character. diff --git a/src/string/strncat.c b/src/string/strncat.c index 8a99f5b4..b455a36c 100644 --- a/src/string/strncat.c +++ b/src/string/strncat.c @@ -1,6 +1,5 @@ #include #include "_safety.h" -#undef strncat /** concatenate bounded string **/ @@ -30,6 +29,8 @@ char * strncat(char * restrict s1, const char * restrict s2, size_t n) return s1; } +__check_3(char *, 0, strncat, char * restrict, const char * restrict, size_t) + /*** appends a copy of the frist ARGUMENT(n) bytes of the string at ARGUMENT(s2) to the end of the string at ARGUMENT(s1). The first byte of ARGUMENT(s2) will diff --git a/src/string/strncat_s.c b/src/string/strncat_s.c index 989ad763..700e8fb7 100644 --- a/src/string/strncat_s.c +++ b/src/string/strncat_s.c @@ -25,6 +25,8 @@ errno_t strncat_s(char * restrict s1, rsize_t s1max, const char * restrict s2, r return 0; } +__check_4(errno_t, 0, strncat_s, char * restrict, rsize_t, const char * restrict, rsize_t) + /*** The fn(strncat) function appends a copy of the frist arg(n) bytes of the string at arg(s2) to the end of the string at arg(s1). The first byte of arg(s2) will diff --git a/src/string/strncmp.c b/src/string/strncmp.c index c5dd573a..bea831b3 100644 --- a/src/string/strncmp.c +++ b/src/string/strncmp.c @@ -24,6 +24,8 @@ int strncmp(const char *s1, const char *s2, size_t n) return memcmp(s1, s2, n); } +__check_3(int, 0, strncmp, const char *, const char *, size_t) + /*** compares up to the first ARGUMENT(n) bytes of the strings at ARGUMENT(s1) and ARGUMENT(s2), or until the first CHAR(\0), whichever comes first. diff --git a/src/string/strncpy.c b/src/string/strncpy.c index 10786ebd..94fcc2f5 100644 --- a/src/string/strncpy.c +++ b/src/string/strncpy.c @@ -24,6 +24,8 @@ char * strncpy(char * restrict s1, const char * restrict s2, size_t n) return s1; } +CHECK_3(char *, 0, strncpy, char * restrict, const char * restrict, size_t) + /*** copies up to ARGUMENT(n) bytes from the string at ARGUMENT(s2) to ARGUMENT(s1). If a CHAR(\0) is encountered, null characters are appended to diff --git a/src/string/strncpy_s.c b/src/string/strncpy_s.c index 1fdb3cb5..81ff253b 100644 --- a/src/string/strncpy_s.c +++ b/src/string/strncpy_s.c @@ -24,6 +24,8 @@ errno_t strncpy_s(char * restrict s1, rsize_t s1max, const char * restrict s2, r return 0; } +CHECK_4(errno_t, 0, strncpy_s, char * restrict, rsize_t, const char *, rsize_t) + /*** The fn(strncpy) function copies up to arg(n) bytes from the string at arg(s2) to arg(s1). If a char(\0) is encountered, null characters are appended to diff --git a/src/string/strnlen_s.c b/src/string/strnlen_s.c index 3755f7d8..7f9084fa 100644 --- a/src/string/strnlen_s.c +++ b/src/string/strnlen_s.c @@ -8,6 +8,8 @@ size_t strnlen_s(const char *s, size_t maxsize) return maxsize; } +CHECK_2(size_t, 0, strnlen_s, const char *, size_t) + /* CEXT1(201112) */ diff --git a/src/string/strpbrk.c b/src/string/strpbrk.c index d238ad89..2d2a95b4 100644 --- a/src/string/strpbrk.c +++ b/src/string/strpbrk.c @@ -21,6 +21,8 @@ char * strpbrk(const char *s1, const char *s2) return NULL; } +CHECK_2(char *, 0, strpbrk, const char *, const char *) + /*** locates the first occurence in ARGUMENT(s1) of any character in ARGUMENT(s2). ***/ diff --git a/src/string/strrchr.c b/src/string/strrchr.c index d7c50e31..c7172590 100644 --- a/src/string/strrchr.c +++ b/src/string/strrchr.c @@ -1,6 +1,5 @@ #include #include "_safety.h" -#undef strrchr /** search string from end **/ @@ -24,6 +23,8 @@ char * strrchr(const char *s, int c) return NULL; } +CHECK_2(char *, 0, strrchr, const char *, int) + /*** finds the last occurence of ARGUMENT(c) (converted to TYPE(char)) in the string ARGUMENT(s). diff --git a/src/string/strspn.c b/src/string/strspn.c index 4d6231e7..156abe06 100644 --- a/src/string/strspn.c +++ b/src/string/strspn.c @@ -20,6 +20,8 @@ size_t strspn(const char *s1, const char *s2) return i; } +CHECK_2(size_t, 0, strspn, const char *, const char *) + /*** computes the length of the maximum initial segment of the ARGUMENT(s1) made up of characters from ARGUMENT(s2). diff --git a/src/string/strstr.c b/src/string/strstr.c index cc2da14a..d4f26f37 100644 --- a/src/string/strstr.c +++ b/src/string/strstr.c @@ -30,6 +30,8 @@ char * strstr(const char *s1, const char *s2) return p; } +CHECK_2(char *, 0, strstr, const char *, const char *) + /*** finds the first occurrence of the string ARGUMENT(s2) in the string ARGUMENT(s1). Specifying the empty string for ARGUMENT(s2) matches the first diff --git a/src/string/strtok.c b/src/string/strtok.c index 862581c7..a1ddeadc 100644 --- a/src/string/strtok.c +++ b/src/string/strtok.c @@ -23,6 +23,8 @@ char * strtok(char * restrict s1, const char * restrict s2) return current; } +CHECK_2(char *, 0, strtok, char * restrict, char * restrict) + /*** splits the string ARGUMENT(s1) into a series of tokens delimited by characters from the string ARGUMENT(s2). diff --git a/src/string/strtok_s.c b/src/string/strtok_s.c index 7721a108..859e4885 100644 --- a/src/string/strtok_s.c +++ b/src/string/strtok_s.c @@ -1,14 +1,15 @@ #include #include "_safety.h" -#undef strtok_s char * strtok_s(char * restrict s1, rsize_t * restrict s1max, const char * restrict s2, char **restrict ptr) { SIGNAL_SAFE(0); (void)s1; (void)s1max; (void)s2; (void)ptr; - return NULL; + return NULL; } +CHECK_4(char *, 0, strtok_s, char * restrict, rsize_t * restrict, const char * restrict, char ** restrict) + /* CEXT1(201112) */ diff --git a/src/string/strxfrm.c b/src/string/strxfrm.c index 2431ba6e..fc16087a 100644 --- a/src/string/strxfrm.c +++ b/src/string/strxfrm.c @@ -18,6 +18,8 @@ size_t strxfrm(char * restrict s1, const char * restrict s2, size_t n) return 0; } +CHECK_3(size_t, 0, strxfrm, char * restrict, const char * restrict, size_t) + /*** transforms up to ARGUMENT(n) bytes of the string at ARGUMENT(s2), placing the transformed string at ARGUMENT(s1). The transformed string is the -- cgit v1.2.1