[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251118-strends-follow-up-v1-2-d3f8ef750f59@linaro.org>
Date: Tue, 18 Nov 2025 11:04:04 +0100
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Kees Cook <kees@...nel.org>, Andy Shevchenko <andy@...nel.org>,
Linus Walleij <linus.walleij@...aro.org>
Cc: linux-hardening@...r.kernel.org, linux-kernel@...r.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
Subject: [PATCH 2/2] string: use __attribute__((nonnull())) in strends()
From: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
The arguments of strends() must not be NULL so annotate the function
with the nonnull attribute.
Suggested-by: Kees Cook <kees@...nel.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
---
include/linux/string.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/linux/string.h b/include/linux/string.h
index 69e9256592f87e446d6f0be5034056aa7d0b78b0..0266dbdaa4cde7a388f1c1d5e8755d7f00335e42 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -570,7 +570,8 @@ static inline bool strstarts(const char *str, const char *prefix)
* Returns:
* True if @str ends with @suffix. False in all other cases.
*/
-static inline bool strends(const char *str, const char *suffix)
+static inline bool __attribute__((nonnull(1, 2)))
+strends(const char *str, const char *suffix)
{
unsigned int str_len = strlen(str), suffix_len = strlen(suffix);
--
2.51.0
Powered by blists - more mailing lists