sync getrrsetbyname.c with recent upstream changes

This commit is contained in:
Damien Miller 2024-05-08 09:43:59 +10:00
parent 385ecb31e1
commit 6a42b70e56
No known key found for this signature in database
1 changed files with 13 additions and 11 deletions

View File

@ -328,13 +328,14 @@ getrrsetbyname(const char *hostname, unsigned int rdclass,
if (rdata) { if (rdata) {
rdata->rdi_length = rr->size; rdata->rdi_length = rr->size;
rdata->rdi_data = malloc(rr->size); if (rr->size != 0) {
rdata->rdi_data = malloc(rr->size);
if (rdata->rdi_data == NULL) { if (rdata->rdi_data == NULL) {
result = ERRSET_NOMEMORY; result = ERRSET_NOMEMORY;
goto fail; goto fail;
}
memcpy(rdata->rdi_data, rr->rdata, rr->size);
} }
memcpy(rdata->rdi_data, rr->rdata, rr->size);
} }
} }
free_dns_response(response); free_dns_response(response);
@ -577,12 +578,13 @@ parse_dns_rrsection(const u_char *answer, int size, const u_char **cp,
/* rdata itself */ /* rdata itself */
NEED(curr->size); NEED(curr->size);
curr->rdata = malloc(curr->size); if (curr->size != 0) {
if (curr->rdata == NULL) { if ((curr->rdata = malloc(curr->size)) == NULL) {
free_dns_rr(head); free_dns_rr(head);
return (NULL); return (NULL);
}
memcpy(curr->rdata, *cp, curr->size);
} }
memcpy(curr->rdata, *cp, curr->size);
*cp += curr->size; *cp += curr->size;
} }
#undef NEED #undef NEED