Skip to content

Commit 9cd22f0

Browse files
committed
Merge pull request #3672 from jes/dnscache-fix
Fix buffer overflow in dnscache (#3669) (cherry picked from commit 0371946)
1 parent 937fecf commit 9cd22f0

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

modules/dns_cache/dns_cache.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ static char* serialize_he_rdata(struct hostent *he,int *buf_len,int do_encoding)
219219

220220
/* copy aliases, if any */
221221
if (he->h_aliases)
222-
for (i=0;he->h_aliases[i];i++) {
222+
for (i=0;i<alias_no;i++) {
223223
len=strlen(he->h_aliases[i])+1;
224224
/* copy alias length */
225225
memcpy(p,&len,sizeof(int));
@@ -235,7 +235,7 @@ static char* serialize_he_rdata(struct hostent *he,int *buf_len,int do_encoding)
235235

236236
/* copy addresses */
237237
if (he->h_addr_list)
238-
for (i=0;he->h_addr_list[i];i++) {
238+
for (i=0;i<addr_no;i++) {
239239
/* copy addreses. length will be known from the addrtype field */
240240
len=he->h_length;
241241
memcpy(p,he->h_addr_list[i],len);

0 commit comments

Comments
 (0)