summaryrefslogtreecommitdiff
path: root/sysklogd
diff options
context:
space:
mode:
authorDenis Vlasenko2008-02-19 01:10:20 +0000
committerDenis Vlasenko2008-02-19 01:10:20 +0000
commit92657d484f4f95ce4579ad095c9caf596a737e5b (patch)
treededed9ccc14fc9bbcff10db7ea9dd72136653b84 /sysklogd
parente8419c90f1f3880f96ff335c4ee0bdd7a86ab0c6 (diff)
downloadbusybox-92657d484f4f95ce4579ad095c9caf596a737e5b.zip
busybox-92657d484f4f95ce4579ad095c9caf596a737e5b.tar.gz
syslogd: tighten up hostname handling.
Diffstat (limited to 'sysklogd')
-rw-r--r--sysklogd/syslogd.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index dc5e625..bed1816 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -649,10 +649,10 @@ int syslogd_main(int argc, char **argv)
/* Store away localhost's name before the fork */
gethostname(G.localHostName, sizeof(G.localHostName));
- p = strchr(G.localHostName, '.');
- if (p) {
- *p = '\0';
- }
+ /* "It is unspecified whether the truncated hostname
+ * will be null-terminated". Idiots! */
+ G.localHostName[sizeof(G.localHostName) - 1] = '\0';
+ *strchrnul(G.localHostName, '.') = '\0';
if (!(option_mask32 & OPT_nofork)) {
bb_daemonize_or_rexec(DAEMON_CHDIR_ROOT, argv);