diff --git a/lib/krb5/krbhst.c b/lib/krb5/krbhst.c index f53512883..1c93b75cb 100644 --- a/lib/krb5/krbhst.c +++ b/lib/krb5/krbhst.c @@ -353,14 +353,14 @@ krb5_krbhst_format_string(krb5_context context, const krb5_krbhst_info *host, char *hostname, size_t hostlen) { const char *proto = ""; - char portstr[7] = ""; if(host->proto == KRB5_KRBHST_TCP) proto = "tcp/"; else if(host->proto == KRB5_KRBHST_HTTP) proto = "http://"; - if(host->port != host->def_port) - snprintf(portstr, sizeof(portstr), ":%d", host->port); - snprintf(hostname, hostlen, "%s%s%s", proto, host->hostname, portstr); + if (host->port != host->def_port) + snprintf(hostname, hostlen, "%s%s:%d", proto, host->hostname, (int)host->port); + else + snprintf(hostname, hostlen, "%s%s", proto, host->hostname); return 0; }