From afa00abb2b68205bee539d7947130d6b1b1ec6e9 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Thu, 1 Apr 2021 19:39:14 +0200 Subject: Hardened entire system By using the nonnull attribute and replace buffer-overflow-prone functions like strcpy, strcat and sprintf by strlcpy, strlcat and snprintf. --- libs/libc/inc/str.h | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'libs/libc/inc/str.h') diff --git a/libs/libc/inc/str.h b/libs/libc/inc/str.h index d0a521f..e77eeee 100644 --- a/libs/libc/inc/str.h +++ b/libs/libc/inc/str.h @@ -5,17 +5,15 @@ #include -u32 strlen(const char *s); -char *strcpy(char *dst, const char *src); -char *strncpy(char *dst, const char *src, u32 n); -char *strchr(char *s, int c); -char *strrchr(char *s, int c); -char *strcat(char *dst, const char *src); -char *strncat(char *dst, const char *src, u32 n); -int strcmp(const char *s1, const char *s2); -int strncmp(const char *s1, const char *s2, u32 n); -char *strinv(char *s); -char *strdup(const char *s); +u32 strlen(const char *s) NONNULL; +u32 strlcpy(char *dst, const char *src, u32 size) NONNULL; +char *strchr(char *s, int c) NONNULL; +char *strrchr(char *s, int c) NONNULL; +u32 strlcat(char *dst, const char *src, u32 size) NONNULL; +int strcmp(const char *s1, const char *s2) NONNULL; +int strncmp(const char *s1, const char *s2, u32 n) NONNULL; +char *strinv(char *s) NONNULL; +char *strdup(const char *s) NONNULL; const char *strerror(u32 err); -- cgit v1.2.3