patch-2.4.9 linux/arch/arm/lib/uaccess-armo.S

Next file: linux/arch/arm/mach-anakin/Makefile
Previous file: linux/arch/arm/lib/io-writesw-armv4.S
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.8/linux/arch/arm/lib/uaccess-armo.S linux/arch/arm/lib/uaccess-armo.S
@@ -96,7 +96,7 @@
 		.word	uaccess_kernel_copy
 		.word	uaccess_kernel_clear
 		.word	uaccess_kernel_strncpy_from
-		.word	uaccess_kernel_strlen
+		.word	uaccess_kernel_strnlen
 
 @ In : r0 = x, r1 = addr, r2 = error
 @ Out: r2 = error
@@ -211,17 +211,21 @@
 2:		subs	r0, ip, r2
 		ldmfd	sp!, {pc}^
 
-/* Prototype: int uaccess_kernel_strlen(char *str)
+/* Prototype: int uaccess_kernel_strlen(char *str, long n)
  * Purpose  : get length of a string in kernel memory
  * Params   : str - address of string in kernel memory
- * Returns  : length of string *including terminator*, or zero on error
+ * Returns  : length of string *including terminator*,
+ *            or zero on exception, or n + 1 if too long
  */
-uaccess_kernel_strlen:
+uaccess_kernel_strnlen:
 		stmfd	sp!, {lr}
 		mov	r2, r0
 1:		ldrb	r1, [r0], #1
 		teq	r1, #0
+		beq	2f
+		subs	r1, r1, #1
 		bne	1b
-		sub	r0, r0, r2
+		add	r0, r0, #1
+2:		sub	r0, r0, r2
 		ldmfd	sp!, {pc}^
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)