Skip to content

Commit

Permalink
lib: Fix printing a short into portstr
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cryptomilk authored and nicowilliams committed Sep 25, 2017
1 parent a79b59b commit ccb63bb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/krb5/krbhst.c
Expand Up @@ -353,13 +353,13 @@ krb5_krbhst_format_string(krb5_context context, const krb5_krbhst_info *host,
char *hostname, size_t hostlen)
{
const char *proto = "";
char portstr[7] = "";
char portstr[7] = {0};
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(portstr, sizeof(portstr), ":%hd", host->port);
snprintf(hostname, hostlen, "%s%s%s", proto, host->hostname, portstr);
return 0;
}
Expand Down

0 comments on commit ccb63bb

Please sign in to comment.