[SPARC]: Fix length parameter verification in sys_getdomainname().
Found by scrashme. Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
8a84eb164c
commit
8310a32c15
|
@ -465,21 +465,21 @@ sys_rt_sigaction(int sig,
|
|||
|
||||
asmlinkage int sys_getdomainname(char __user *name, int len)
|
||||
{
|
||||
int nlen;
|
||||
int err = -EFAULT;
|
||||
int nlen, err;
|
||||
|
||||
if (len < 0 || len > __NEW_UTS_LEN)
|
||||
return -EINVAL;
|
||||
|
||||
down_read(&uts_sem);
|
||||
|
||||
nlen = strlen(system_utsname.domainname) + 1;
|
||||
|
||||
if (nlen < len)
|
||||
len = nlen;
|
||||
if (len > __NEW_UTS_LEN)
|
||||
goto done;
|
||||
if (copy_to_user(name, system_utsname.domainname, len))
|
||||
goto done;
|
||||
|
||||
err = -EFAULT;
|
||||
if (!copy_to_user(name, system_utsname.domainname, len))
|
||||
err = 0;
|
||||
done:
|
||||
|
||||
up_read(&uts_sem);
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -701,21 +701,21 @@ extern void check_pending(int signum);
|
|||
|
||||
asmlinkage long sys_getdomainname(char __user *name, int len)
|
||||
{
|
||||
int nlen;
|
||||
int err = -EFAULT;
|
||||
int nlen, err;
|
||||
|
||||
if (len < 0 || len > __NEW_UTS_LEN)
|
||||
return -EINVAL;
|
||||
|
||||
down_read(&uts_sem);
|
||||
|
||||
nlen = strlen(system_utsname.domainname) + 1;
|
||||
|
||||
if (nlen < len)
|
||||
len = nlen;
|
||||
if (len > __NEW_UTS_LEN)
|
||||
goto done;
|
||||
if (copy_to_user(name, system_utsname.domainname, len))
|
||||
goto done;
|
||||
|
||||
err = -EFAULT;
|
||||
if (!copy_to_user(name, system_utsname.domainname, len))
|
||||
err = 0;
|
||||
done:
|
||||
|
||||
up_read(&uts_sem);
|
||||
return err;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue