From: Andy Whitcroft <apw@shadowen.org>
To: linux-kernel@vger.kernel.org
Cc: akpm@osdl.org, apw@shadowen.org
Subject: sysctl uts write size
Date: Tue, 8 Jun 2004 12:49:35 +0100 [thread overview]
Message-ID: <200406081149.i58BnZHD026164@voidhawk.shadowen.org> (raw)
The sysctl interfaces for updating the uts entries such as hostname
and domainname are using the wrong length for these buffers; they are
hard coded to 64. Although safe, this artifically limits the size
of these fields to one less than the true maximum. This generates an
inconsistency between the various methods of update for these fields.
# hostname 12345678901234567890123456789012345678901234567890123456789012345
hostname: name too long
# hostname 1234567890123456789012345678901234567890123456789012345678901234
# hostname
1234567890123456789012345678901234567890123456789012345678901234
# sysctl -w kernel.hostname=1234567890123456789012345678901234567890123456789012345678901234567890
kernel.hostname = 1234567890123456789012345678901234567890123456789012345678901234567890
# hostname
123456789012345678901234567890123456789012345678901234567890123
#
The error originates from the fact the handler for strings (proc_dostring)
already allows for the string terminator. This patch corrects the
limit, taking the oppotunity to convert to use of sizeof().
Signed-off-by: Andy Whitcroft <apw@shadowen.org>
---
sysctl.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff -X /home/apw/lib/vdiff.excl -rupN reference/kernel/sysctl.c current/kernel/sysctl.c
--- reference/kernel/sysctl.c 2004-05-10 14:55:16.000000000 +0100
+++ current/kernel/sysctl.c 2004-06-08 13:26:23.000000000 +0100
@@ -218,7 +218,7 @@ static ctl_table kern_table[] = {
.ctl_name = KERN_OSTYPE,
.procname = "ostype",
.data = system_utsname.sysname,
- .maxlen = 64,
+ .maxlen = sizeof(system_utsname.sysname),
.mode = 0444,
.proc_handler = &proc_doutsstring,
.strategy = &sysctl_string,
@@ -227,7 +227,7 @@ static ctl_table kern_table[] = {
.ctl_name = KERN_OSRELEASE,
.procname = "osrelease",
.data = system_utsname.release,
- .maxlen = 64,
+ .maxlen = sizeof(system_utsname.release),
.mode = 0444,
.proc_handler = &proc_doutsstring,
.strategy = &sysctl_string,
@@ -236,7 +236,7 @@ static ctl_table kern_table[] = {
.ctl_name = KERN_VERSION,
.procname = "version",
.data = system_utsname.version,
- .maxlen = 64,
+ .maxlen = sizeof(system_utsname.version),
.mode = 0444,
.proc_handler = &proc_doutsstring,
.strategy = &sysctl_string,
@@ -245,7 +245,7 @@ static ctl_table kern_table[] = {
.ctl_name = KERN_NODENAME,
.procname = "hostname",
.data = system_utsname.nodename,
- .maxlen = 64,
+ .maxlen = sizeof(system_utsname.nodename),
.mode = 0644,
.proc_handler = &proc_doutsstring,
.strategy = &sysctl_string,
@@ -254,7 +254,7 @@ static ctl_table kern_table[] = {
.ctl_name = KERN_DOMAINNAME,
.procname = "domainname",
.data = system_utsname.domainname,
- .maxlen = 64,
+ .maxlen = sizeof(system_utsname.domainname),
.mode = 0644,
.proc_handler = &proc_doutsstring,
.strategy = &sysctl_string,
reply other threads:[~2004-06-08 12:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200406081149.i58BnZHD026164@voidhawk.shadowen.org \
--to=apw@shadowen.org \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®