lib: Fix printing a short into portstr
The size of portstr is too small to print an integer and we should print a short anyway. This fixes building with GCC 7.1
This commit is contained in:

committed by
Nico Williams

parent
a79b59ba27
commit
ccb63bb0aa
@@ -353,13 +353,13 @@ krb5_krbhst_format_string(krb5_context context, const krb5_krbhst_info *host,
|
|||||||
char *hostname, size_t hostlen)
|
char *hostname, size_t hostlen)
|
||||||
{
|
{
|
||||||
const char *proto = "";
|
const char *proto = "";
|
||||||
char portstr[7] = "";
|
char portstr[7] = {0};
|
||||||
if(host->proto == KRB5_KRBHST_TCP)
|
if(host->proto == KRB5_KRBHST_TCP)
|
||||||
proto = "tcp/";
|
proto = "tcp/";
|
||||||
else if(host->proto == KRB5_KRBHST_HTTP)
|
else if(host->proto == KRB5_KRBHST_HTTP)
|
||||||
proto = "http://";
|
proto = "http://";
|
||||||
if(host->port != host->def_port)
|
if(host->port != host->def_port)
|
||||||
snprintf(portstr, sizeof(portstr), ":%d", host->port);
|
snprintf(portstr, sizeof(portstr), ":%hd", host->port);
|
||||||
snprintf(hostname, hostlen, "%s%s%s", proto, host->hostname, portstr);
|
snprintf(hostname, hostlen, "%s%s%s", proto, host->hostname, portstr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user