From: Denis Vlasenko Date: Tue, 19 Feb 2008 01:10:20 +0000 (-0000) Subject: syslogd: tighten up hostname handling. X-Git-Tag: 1_10_0~136 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=92657d484f4f95ce4579ad095c9caf596a737e5b;p=platform%2Fupstream%2Fbusybox.git syslogd: tighten up hostname handling. --- 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);