aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/utils/host.c
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2008-05-09 11:34:58 +0000
committerMartin Willi <martin@strongswan.org>2008-05-09 11:34:58 +0000
commit9f9903a3b36c1da9c4add58a2014647f48cb9c7c (patch)
treeb1aca5facd42bf4a5d7253fb477c31c74313e3e9 /src/libstrongswan/utils/host.c
parentff2d02ed4ce38e4498cf61f5f66f51fdbf4b971f (diff)
downloadstrongswan-9f9903a3b36c1da9c4add58a2014647f48cb9c7c.tar.bz2
strongswan-9f9903a3b36c1da9c4add58a2014647f48cb9c7c.tar.xz
supporting width modifier in identification_t printf hook (e.g. %30D)
cleanups in host_t %H printf hook
Diffstat (limited to 'src/libstrongswan/utils/host.c')
-rw-r--r--src/libstrongswan/utils/host.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/libstrongswan/utils/host.c b/src/libstrongswan/utils/host.c
index ca94c99c5..aab0f092f 100644
--- a/src/libstrongswan/utils/host.c
+++ b/src/libstrongswan/utils/host.c
@@ -107,15 +107,14 @@ static int print(FILE *stream, const struct printf_info *info,
{
private_host_t *this = *((private_host_t**)(args[0]));
char buffer[INET6_ADDRSTRLEN + 16];
- int len;
if (this == NULL)
{
- len = sprintf(buffer, "(null)");
+ snprintf(buffer, sizeof(buffer), "(null)");
}
else if (is_anyaddr(this))
{
- len = sprintf(buffer, "%%any");
+ snprintf(buffer, sizeof(buffer), "%%any");
}
else
{
@@ -136,15 +135,17 @@ static int print(FILE *stream, const struct printf_info *info,
if (inet_ntop(this->address.sa_family, address,
buffer, sizeof(buffer)) == NULL)
{
- len = sprintf(buffer, "(address conversion failed)");
+ snprintf(buffer, sizeof(buffer),
+ "(address conversion failed)");
}
else if (info->alt)
{
- len = sprintf(buffer, "%s[%d]", buffer, ntohs(port));
+ snprintf(buffer, sizeof(buffer),
+ "%s[%d]", buffer, ntohs(port));
}
break;
default:
- len = sprintf(buffer, "(family not supported)");
+ snprintf(buffer, sizeof(buffer), "(family not supported)");
break;
}
}