diff options
author | Greg Hudson <ghudson@mit.edu> | 2009-11-23 19:24:42 +0000 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 2009-11-23 19:24:42 +0000 |
commit | c64cae69c04d86c3807574c4547de752f0dcea1d (patch) | |
tree | c6a9317ae6ccfa4553fb3b90c1c8aaee710df70d /src/lib/kadm5/logger.c | |
parent | 57c6b7049e6c2025cb020927f5f731e9f16bb702 (diff) | |
download | krb5-c64cae69c04d86c3807574c4547de752f0dcea1d.zip krb5-c64cae69c04d86c3807574c4547de752f0dcea1d.tar.gz krb5-c64cae69c04d86c3807574c4547de752f0dcea1d.tar.bz2 |
Check return value of gethostname in krb5_klog_init
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23313 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/kadm5/logger.c')
-rw-r--r-- | src/lib/kadm5/logger.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/lib/kadm5/logger.c b/src/lib/kadm5/logger.c index b8da209..a3f4339 100644 --- a/src/lib/kadm5/logger.c +++ b/src/lib/kadm5/logger.c @@ -668,8 +668,11 @@ krb5_klog_init(krb5_context kcontext, char *ename, char *whoami, krb5_boolean do log_control.log_whoami = strdup(whoami); log_control.log_hostname = (char *) malloc(MAXHOSTNAMELEN + 1); if (log_control.log_hostname) { - gethostname(log_control.log_hostname, MAXHOSTNAMELEN); - log_control.log_hostname[MAXHOSTNAMELEN] = '\0'; + if (gethostname(log_control.log_hostname, MAXHOSTNAMELEN) == -1) { + free(log_control.log_hostname); + log_control.log_hostname = NULL; + } else + log_control.log_hostname[MAXHOSTNAMELEN] = '\0'; } #ifdef HAVE_OPENLOG if (do_openlog) { |