Skip to content

Commit

Permalink
sync getrrsetbyname.c with recent upstream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
djmdjm committed May 7, 2024
1 parent 385ecb3 commit 6a42b70
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions openbsd-compat/getrrsetbyname.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,14 @@ getrrsetbyname(const char *hostname, unsigned int rdclass,

if (rdata) {
rdata->rdi_length = rr->size;
rdata->rdi_data = malloc(rr->size);

if (rdata->rdi_data == NULL) {
result = ERRSET_NOMEMORY;
goto fail;
if (rr->size != 0) {
rdata->rdi_data = malloc(rr->size);
if (rdata->rdi_data == NULL) {
result = ERRSET_NOMEMORY;
goto fail;
}
memcpy(rdata->rdi_data, rr->rdata, rr->size);
}
memcpy(rdata->rdi_data, rr->rdata, rr->size);
}
}
free_dns_response(response);
Expand Down Expand Up @@ -577,12 +578,13 @@ parse_dns_rrsection(const u_char *answer, int size, const u_char **cp,

/* rdata itself */
NEED(curr->size);
curr->rdata = malloc(curr->size);
if (curr->rdata == NULL) {
free_dns_rr(head);
return (NULL);
if (curr->size != 0) {
if ((curr->rdata = malloc(curr->size)) == NULL) {
free_dns_rr(head);
return (NULL);
}
memcpy(curr->rdata, *cp, curr->size);
}
memcpy(curr->rdata, *cp, curr->size);
*cp += curr->size;
}
#undef NEED
Expand Down

0 comments on commit 6a42b70

Please sign in to comment.