fixed printing of %#H hosts
authorMartin Willi <martin@strongswan.org>
Wed, 14 May 2008 06:34:54 +0000 (06:34 -0000)
committerMartin Willi <martin@strongswan.org>
Wed, 14 May 2008 06:34:54 +0000 (06:34 -0000)
src/libstrongswan/utils/host.c

index bde7dc1..a2fa579 100644 (file)
@@ -120,6 +120,7 @@ static int print(FILE *stream, const struct printf_info *info,
        {
                void *address;
                u_int16_t port;
        {
                void *address;
                u_int16_t port;
+               int len;
                
                address = &this->address6.sin6_addr;
                port = this->address6.sin6_port;
                
                address = &this->address6.sin6_addr;
                port = this->address6.sin6_port;
@@ -140,8 +141,9 @@ static int print(FILE *stream, const struct printf_info *info,
                                }
                                else if (info->alt)
                                {
                                }
                                else if (info->alt)
                                {
-                                       snprintf(buffer, sizeof(buffer),
-                                                        "%s[%d]", buffer, ntohs(port));
+                                       len = strlen(buffer);
+                                       snprintf(buffer + len, sizeof(buffer) - len,
+                                                        "[%d]", ntohs(port));
                                }
                                break;
                        default:
                                }
                                break;
                        default: