[SPARC]: Fix regression in sys_getdomainname()

This patch corrects the buffer length checking in the
sys_getdomainname() implementation for sparc/sparc64.

Signed-off-by: Andy Walker <andy@puszczka.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Andy Walker 2006-09-18 07:11:36 -07:00 committed by David S. Miller
parent b9b64e6e89
commit b9c54f91a4
2 changed files with 12 additions and 8 deletions

View file

@ -470,19 +470,21 @@ asmlinkage int sys_getdomainname(char __user *name, int len)
{
int nlen, err;
if (len < 0 || len > __NEW_UTS_LEN)
if (len < 0)
return -EINVAL;
down_read(&uts_sem);
nlen = strlen(system_utsname.domainname) + 1;
if (nlen < len)
len = nlen;
err = -EINVAL;
if (nlen > len)
goto out;
err = -EFAULT;
if (!copy_to_user(name, system_utsname.domainname, len))
if (!copy_to_user(name, system_utsname.domainname, nlen))
err = 0;
out:
up_read(&uts_sem);
return err;
}

View file

@ -707,19 +707,21 @@ asmlinkage long sys_getdomainname(char __user *name, int len)
{
int nlen, err;
if (len < 0 || len > __NEW_UTS_LEN)
if (len < 0)
return -EINVAL;
down_read(&uts_sem);
nlen = strlen(system_utsname.domainname) + 1;
if (nlen < len)
len = nlen;
err = -EINVAL;
if (nlen > len)
goto out;
err = -EFAULT;
if (!copy_to_user(name, system_utsname.domainname, len))
if (!copy_to_user(name, system_utsname.domainname, nlen))
err = 0;
out:
up_read(&uts_sem);
return err;
}