From cb6ac9b911f1ede63726b4f85a520b79c3d91f4c Mon Sep 17 00:00:00 2001 From: hunt Date: Wed, 12 Jul 2006 06:14:17 +0000 Subject: 2006-07-11 Martin Hunt * string.c (_stp_text_str): Use __get_user(). --- runtime/string.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'runtime/string.c') diff --git a/runtime/string.c b/runtime/string.c index 21a6c70e..740a7567 100644 --- a/runtime/string.c +++ b/runtime/string.c @@ -212,7 +212,6 @@ char * _stp_string_ptr (String str) } \ }) -#include "loc2c-runtime.h" /** Return a printable text string. * @@ -240,9 +239,12 @@ void _stp_text_str(char *outstr, char *in, int len, int quoted, int user) *out++ = '\"'; } - if (user) - c = deref(1,(char __user *)in); - else + if (user) { + if (!access_ok(VERIFY_READ, (char __user *)in, len)) + goto bad; + if (__get_user(c, (char __user *)in) < 0) + goto bad; + } else c = *in; while (c && len > 0) { @@ -307,9 +309,10 @@ void _stp_text_str(char *outstr, char *in, int len, int quoted, int user) } len -= num; in++; - if (user) - c = deref(1,(char __user *)in); - else + if (user) { + if (__get_user(c, (char __user *)in) < 0) + goto bad; + } else c = *in; } @@ -325,7 +328,7 @@ void _stp_text_str(char *outstr, char *in, int len, int quoted, int user) } *out = '\0'; return; -deref_fault: +bad: strlcpy (outstr, "", len); } -- cgit