Skip to content

Commit

Permalink
osf_getdomainname(): use copy_to_user()
Browse files Browse the repository at this point in the history
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed May 27, 2017
1 parent 2ea659a commit 9ba3eb5
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions arch/alpha/kernel/osf_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/*
Expand Down

0 comments on commit 9ba3eb5

Please sign in to comment.