Commit 77bc0283 authored by Al Viro's avatar Al Viro Committed by Kleber Sacilotto de Souza

osf_getdomainname(): use copy_to_user()

BugLink: https://bugs.launchpad.net/bugs/1792419

commit 9ba3eb51 upstream.
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 33f032cf
...@@ -561,25 +561,20 @@ SYSCALL_DEFINE0(getdtablesize) ...@@ -561,25 +561,20 @@ SYSCALL_DEFINE0(getdtablesize)
*/ */
SYSCALL_DEFINE2(osf_getdomainname, char __user *, name, int, namelen) SYSCALL_DEFINE2(osf_getdomainname, char __user *, name, int, namelen)
{ {
unsigned len; int len, err = 0;
int i; char *kname;
if (!access_ok(VERIFY_WRITE, name, namelen)) if (namelen > 32)
return -EFAULT; namelen = 32;
len = namelen;
if (len > 32)
len = 32;
down_read(&uts_sem); down_read(&uts_sem);
for (i = 0; i < len; ++i) { kname = utsname()->domainname;
__put_user(utsname()->domainname[i], name + i); len = strnlen(kname, namelen);
if (utsname()->domainname[i] == '\0') if (copy_to_user(name, kname, min(len + 1, namelen)))
break; err = -EFAULT;
}
up_read(&uts_sem); up_read(&uts_sem);
return 0; return err;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment