diff options
Diffstat (limited to 'sysklogd')
-rw-r--r-- | sysklogd/syslogd.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index 0dc69d8cc..0d004bc27 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c | |||
@@ -97,8 +97,8 @@ struct globals { | |||
97 | struct shbuf_ds *shbuf; | 97 | struct shbuf_ds *shbuf; |
98 | #endif | 98 | #endif |
99 | time_t last_log_time; | 99 | time_t last_log_time; |
100 | /* localhost's name */ | 100 | /* localhost's name. We print only first 64 chars */ |
101 | char localHostName[64]; | 101 | char *hostname; |
102 | 102 | ||
103 | /* We recv into recvbuf... */ | 103 | /* We recv into recvbuf... */ |
104 | char recvbuf[MAX_READ]; | 104 | char recvbuf[MAX_READ]; |
@@ -416,7 +416,7 @@ static void timestamp_and_log(int pri, char *msg, int len) | |||
416 | else { | 416 | else { |
417 | char res[20]; | 417 | char res[20]; |
418 | parse_fac_prio_20(pri, res); | 418 | parse_fac_prio_20(pri, res); |
419 | sprintf(G.printbuf, "%s %s %s %s\n", timestamp, G.localHostName, res, msg); | 419 | sprintf(G.printbuf, "%s %.64s %s %s\n", timestamp, G.hostname, res, msg); |
420 | } | 420 | } |
421 | 421 | ||
422 | /* Log message locally (to file or shared mem) */ | 422 | /* Log message locally (to file or shared mem) */ |
@@ -647,11 +647,8 @@ int syslogd_main(int argc, char **argv) | |||
647 | option_mask32 |= OPT_locallog; | 647 | option_mask32 |= OPT_locallog; |
648 | 648 | ||
649 | /* Store away localhost's name before the fork */ | 649 | /* Store away localhost's name before the fork */ |
650 | /* "It is unspecified whether the truncated hostname | 650 | G.hostname = safe_gethostname(); |
651 | * will be null-terminated". We give it (size - 1), | 651 | *strchrnul(G.hostname, '.') = '\0'; |
652 | * thus last byte will be NUL no matter what. */ | ||
653 | gethostname(G.localHostName, sizeof(G.localHostName) - 1); | ||
654 | *strchrnul(G.localHostName, '.') = '\0'; | ||
655 | 652 | ||
656 | if (!(option_mask32 & OPT_nofork)) { | 653 | if (!(option_mask32 & OPT_nofork)) { |
657 | bb_daemonize_or_rexec(DAEMON_CHDIR_ROOT, argv); | 654 | bb_daemonize_or_rexec(DAEMON_CHDIR_ROOT, argv); |