diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2017-05-13 21:39:49 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2017-05-27 16:21:19 -0400 |
commit | 9ba3eb5103cf56f0daaf07de4507df76e7813ed7 (patch) | |
tree | d6766344879e985bf1226cf9534f6a8a9172f6f5 /arch/alpha/kernel/osf_sys.c | |
parent | 2ea659a9ef488125eb46da6eb571de5eae5c43f6 (diff) | |
download | linux-stable-9ba3eb5103cf56f0daaf07de4507df76e7813ed7.tar.gz linux-stable-9ba3eb5103cf56f0daaf07de4507df76e7813ed7.tar.bz2 linux-stable-9ba3eb5103cf56f0daaf07de4507df76e7813ed7.zip |
osf_getdomainname(): use copy_to_user()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch/alpha/kernel/osf_sys.c')
-rw-r--r-- | arch/alpha/kernel/osf_sys.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c index 9ec56dc97374..c4e135db1704 100644 --- a/arch/alpha/kernel/osf_sys.c +++ b/arch/alpha/kernel/osf_sys.c @@ -564,25 +564,20 @@ SYSCALL_DEFINE0(getdtablesize) */ SYSCALL_DEFINE2(osf_getdomainname, char __user *, name, int, namelen) { - unsigned len; - int i; + int len, err = 0; + char *kname; - if (!access_ok(VERIFY_WRITE, name, namelen)) - return -EFAULT; - - len = namelen; - if (len > 32) - len = 32; + if (namelen > 32) + namelen = 32; down_read(&uts_sem); - for (i = 0; i < len; ++i) { - __put_user(utsname()->domainname[i], name + i); - if (utsname()->domainname[i] == '\0') - break; - } + kname = utsname()->domainname; + len = strnlen(kname, namelen); + if (copy_to_user(name, kname, min(len + 1, namelen))) + err = -EFAULT; up_read(&uts_sem); - return 0; + return err; } /* |