lkml.org 
[lkml]   [2003]   [Jul]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectPATCH: fix failed sethostname corrupting the data
(Stephan Maciej)
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux-2.6.0-test1/kernel/sys.c linux-2.6.0-test1-ac2/kernel/sys.c
--- linux-2.6.0-test1/kernel/sys.c 2003-07-14 14:11:57.000000000 +0100
+++ linux-2.6.0-test1-ac2/kernel/sys.c 2003-07-14 14:56:29.000000000 +0100
@@ -1159,6 +1167,7 @@
asmlinkage long sys_sethostname(char __user *name, int len)
{
int errno;
+ char tmp[__NEW_UTS_LEN];

if (!capable(CAP_SYS_ADMIN))
return -EPERM;
@@ -1166,7 +1175,8 @@
return -EINVAL;
down_write(&uts_sem);
errno = -EFAULT;
- if (!copy_from_user(system_utsname.nodename, name, len)) {
+ if (!copy_from_user(tmp, name, len)) {
+ memcpy(system_utsname.nodename, tmp, len);
system_utsname.nodename[len] = 0;
errno = 0;
}
@@ -1198,6 +1208,7 @@
asmlinkage long sys_setdomainname(char __user *name, int len)
{
int errno;
+ char tmp[__NEW_UTS_LEN];

if (!capable(CAP_SYS_ADMIN))
return -EPERM;
@@ -1206,9 +1217,10 @@

down_write(&uts_sem);
errno = -EFAULT;
- if (!copy_from_user(system_utsname.domainname, name, len)) {
- errno = 0;
+ if (!copy_from_user(tmp, name, len)) {
+ memcpy(system_utsname.domainname, tmp, len);
system_utsname.domainname[len] = 0;
+ errno = 0;
}
up_write(&uts_sem);
return errno;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 13:46    [W:0.024 / U:0.892 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site