patch-2.3.22 linux/include/asm-ppc/uaccess.h
Next file: linux/include/linux/adb.h
Previous file: linux/include/asm-ppc/keyboard.h
Back to the patch index
Back to the overall index
- Lines: 28
- Date:
Tue Oct 12 10:00:58 1999
- Orig file:
v2.3.21/linux/include/asm-ppc/uaccess.h
- Orig date:
Tue Aug 31 17:29:14 1999
diff -u --recursive --new-file v2.3.21/linux/include/asm-ppc/uaccess.h linux/include/asm-ppc/uaccess.h
@@ -259,7 +259,26 @@
* Return 0 for error
*/
-extern long strlen_user(const char *);
+extern int __strnlen_user(const char *str, long len, unsigned long top);
+
+/*
+ * Returns the length of the string at str (including the null byte),
+ * or 0 if we hit a page we can't access,
+ * or something > len if we didn't find a null byte.
+ *
+ * The `top' parameter to __strnlen_user is to make sure that
+ * we can never overflow from the user area into kernel space.
+ */
+extern __inline__ int strnlen_user(const char *str, long len)
+{
+ unsigned long top = __kernel_ok? ~0UL: TASK_SIZE - 1;
+
+ if ((unsigned long)str > top)
+ return 0;
+ return __strnlen_user(str, len, top);
+}
+
+#define strlen_user(str) strnlen_user((str), 0x7ffffffe)
#endif /* __ASSEMBLY__ */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)