lib: Clarify the return value of strnlen_user()
PATCH 1/1 lib: Clarify the return value of strnlen_user()
strnlen_user() can return a number in a range 0 to count + sizeof(unsigned long) - 1. Clarify the comment at the top of the function so that users don't think the function returns at most count+1.
Signed-off-by Jan Kara <[email protected]>
--- lib/strnlen_user.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/strnlen_user.c +2 -1
@@ -89,7 +89,8 @@ static inline long do_strnlen_user(const char __user *src, unsigned long count,* Get the size of a NUL-terminated string in user space. * * Returns the size of the string INCLUDING the terminating NUL. -* If the string is too long, returns 'count+1'. +* If the string is too long, returns a number larger than @count. User +* has to check the return value against "> count". * On exception (or invalid count), returns 0. */ long strnlen_user (const char __user *str,long count)
Signature · 1 line
2.1.4
Quoted 3 lines · Jan Kara
strnlen_user()can return a number in a range 0 to count + sizeof(unsigned long) - 1. Clarify the comment at the top of the function so that users don't think the function returns at most count+1.
Thanks. I also extended the comment (in the same commit) on commentary on avoiding use of this function entirely.
Linus