Skip to content

Commit

Permalink
MIPS: Fix strnlen_user() return value in case of overlong strings.
Browse files Browse the repository at this point in the history
We were returning maxlen like the userland strnlen if no '\0' character
was encountered while the kernel version is expected to return a value
larger than maxlen.  Fixed to return maxlen + 1.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
  • Loading branch information
Ralf Baechle committed Nov 4, 2014
1 parent 30fa053 commit 0097761
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions arch/mips/lib/strnlen_user.S
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ FEXPORT(__strnlen_\func\()_nocheck_asm)
.else
EX(lbe, t0, (v0), .Lfault\@)
.endif
PTR_ADDIU v0, 1
.set noreorder
bnez t0, 1b
1: PTR_SUBU v0, a0
1: PTR_ADDIU v0, 1
.set reorder
PTR_SUBU v0, a0
jr ra
END(__strnlen_\func\()_asm)

Expand Down

0 comments on commit 0097761

Please sign in to comment.