heimdal: Fix printing a short int into a string
The size of portstr is too small to print an integer. Instead just let snprintf do the work. This fixes building with GCC 7.1 Based on feedback by Jeffrey Altman BUG: https://bugzilla.samba.org/show_bug.cgi?id=12930 (Inspired by Samba commit abd74c3ba5e3ee3f5320bff6ed7dff4fbcb79373) Signed-off-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:

committed by
Luke Howard

parent
a3d8951df5
commit
2ea34666d9
@@ -353,14 +353,14 @@ 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] = "";
|
|
||||||
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(hostname, hostlen, "%s%s:%d", proto, host->hostname, (int)host->port);
|
||||||
snprintf(hostname, hostlen, "%s%s%s", proto, host->hostname, portstr);
|
else
|
||||||
|
snprintf(hostname, hostlen, "%s%s", proto, host->hostname);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user