Browse code

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

(cherry picked from commit d6f313e61b3318924e6653c8ca1184b2016f701d)
(cherry picked from commit e1b60b857f78ec459ae31a4cf6475643ec102f40)
(cherry picked from commit d51575098ddaea40304c757a297ba7ec53745f8d)

Daniel-Constantin Mierla authored on 26/10/2015 20:31:59
Showing 1 changed files
... ...
@@ -757,14 +757,14 @@ static inline char* suip2a(union sockaddr_union* su, int su_len)
757 757
 			return "<addr. error>";
758 758
 		buf[0]='[';
759 759
 		offs=1+ip6tosbuf((unsigned char*)su->sin6.sin6_addr.s6_addr, &buf[1],
760
-							sizeof(buf)-4);
760
+							IP6_MAX_STR_SIZE);
761 761
 		buf[offs]=']';
762 762
 		offs++;
763 763
 	}else
764 764
 	if (unlikely(su_len<sizeof(su->sin)))
765 765
 		return "<addr. error>";
766 766
 	else
767
-		offs=ip4tosbuf((unsigned char*)&su->sin.sin_addr, buf, sizeof(buf)-2);
767
+		offs=ip4tosbuf((unsigned char*)&su->sin.sin_addr, buf, IP4_MAX_STR_SIZE);
768 768
 	buf[offs]=0;
769 769
 	return buf;
770 770
 }