Browse Source

Make sure to always terminate decoded string

Write a terminating '\0' to dest when the first byte of the encoded data
is 0. This corner case was previously missed.

Signed-off-by: Daniel Fahlgren <daniel@fahlgren.se>
Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
Waldemar Brodkorb 8 years ago
parent
commit
405c9b96cb
1 changed files with 1 additions and 0 deletions
  1. 1 0
      libc/inet/resolv.c

+ 1 - 0
libc/inet/resolv.c

@@ -674,6 +674,7 @@ int __decode_dotted(const unsigned char *packet,
 	if (!packet)
 		return -1;
 
+	dest[0] = '\0';
 	while (--maxiter) {
 		if (offset >= packet_len)
 			return -1;