[sr-dev] git:master:d6f313e6: core: fixed passed buffer size in suip2a() for ipv6

Daniel-Constantin Mierla miconda at gmail.com
Mon Oct 26 21:37:27 CET 2015


Module: kamailio
Branch: master
Commit: d6f313e61b3318924e6653c8ca1184b2016f701d
URL: https://github.com/kamailio/kamailio/commit/d6f313e61b3318924e6653c8ca1184b2016f701d

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2015-10-26T21:31:59+01:00

core: fixed passed buffer size in suip2a() for ipv6

- buffer size set to IP6_MAX_STR_SIZE, it was too short and returned
  value was empty addres "[]"
- the function is used only by siptrace
- patch from github pull request #381

---

Modified: ip_addr.h

---

Diff:  https://github.com/kamailio/kamailio/commit/d6f313e61b3318924e6653c8ca1184b2016f701d.diff
Patch: https://github.com/kamailio/kamailio/commit/d6f313e61b3318924e6653c8ca1184b2016f701d.patch

---

diff --git a/ip_addr.h b/ip_addr.h
index bce06fa..20176b0 100644
--- a/ip_addr.h
+++ b/ip_addr.h
@@ -741,14 +741,14 @@ static inline char* suip2a(union sockaddr_union* su, int su_len)
 			return "<addr. error>";
 		buf[0]='[';
 		offs=1+ip6tosbuf((unsigned char*)su->sin6.sin6_addr.s6_addr, &buf[1],
-							sizeof(buf)-4);
+							IP6_MAX_STR_SIZE);
 		buf[offs]=']';
 		offs++;
 	}else
 	if (unlikely(su_len<sizeof(su->sin)))
 		return "<addr. error>";
 	else
-		offs=ip4tosbuf((unsigned char*)&su->sin.sin_addr, buf, sizeof(buf)-2);
+		offs=ip4tosbuf((unsigned char*)&su->sin.sin_addr, buf, IP4_MAX_STR_SIZE);
 	buf[offs]=0;
 	return buf;
 }




More information about the sr-dev mailing list