From: Greg Hudson Date: Mon, 23 Nov 2009 19:24:42 +0000 (+0000) Subject: Check return value of gethostname in krb5_klog_init X-Git-Tag: krb5-1.8-alpha1~158 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c64cae69c04d86c3807574c4547de752f0dcea1d;p=krb5.git Check return value of gethostname in krb5_klog_init git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23313 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/kadm5/logger.c b/src/lib/kadm5/logger.c index b8da20955..a3f433910 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) {