[libvirt] [PATCH] network utilities: Allocate space for terminating NUL in virSocketFormatAddr

Matthew Booth mbooth at redhat.com
Wed Nov 4 11:00:14 UTC 2009


* src/util/network.c: Allocate an additional byte for virSocketFormatAddr's
  return buffer
---
 src/util/network.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/util/network.c b/src/util/network.c
index 56426e7..f6588c7 100644
--- a/src/util/network.c
+++ b/src/util/network.c
@@ -135,12 +135,12 @@ virSocketFormatAddr(virSocketAddrPtr addr) {
         return NULL;
 
     if (addr->stor.ss_family == AF_INET) {
-        outlen = INET_ADDRSTRLEN;
+        outlen = INET_ADDRSTRLEN + 1;
         inaddr = &addr->inet4.sin_addr;
     }
 
     else if (addr->stor.ss_family == AF_INET6) {
-        outlen = INET6_ADDRSTRLEN;
+        outlen = INET6_ADDRSTRLEN + 1;
         inaddr = &addr->inet6.sin6_addr;
     }
 
-- 
1.6.2.5




More information about the libvir-list mailing list