* [PATCH] lib: Clarify the return value of strnlen_user()
@ 2015-06-03 13:50 Jan Kara
2015-06-03 15:01 ` Linus Torvalds
0 siblings, 1 reply; 2+ messages in thread
From: Jan Kara @ 2015-06-03 13:50 UTC (permalink / raw)
To: Linus Torvalds; +Cc: LKML, 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.
Signed-off-by: Jan Kara <jack@suse.cz>
---
lib/strnlen_user.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
index fd03ae980013..77bc67222b9d 100644
--- a/lib/strnlen_user.c
+++ b/lib/strnlen_user.c
@@ -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)
--
2.1.4
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-06-03 15:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-03 13:50 [PATCH] lib: Clarify the return value of strnlen_user() Jan Kara
2015-06-03 15:01 ` Linus Torvalds
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®