-/* $OpenBSD: getrrsetbyname_async.c,v 1.13 2023/03/15 22:12:00 millert Exp $ */
+/* $OpenBSD: getrrsetbyname_async.c,v 1.14 2024/05/07 23:40:53 djm Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
/* The rest of this file is taken from the original implementation. */
-/* $OpenBSD: getrrsetbyname_async.c,v 1.13 2023/03/15 22:12:00 millert Exp $ */
+/* $OpenBSD: getrrsetbyname_async.c,v 1.14 2024/05/07 23:40:53 djm Exp $ */
/*
* Copyright (c) 2001 Jakob Schlyter. All rights reserved.
if (rdata) {
rdata->rdi_length = rr->size;
- rdata->rdi_data = malloc(rr->size);
-
- if (rdata->rdi_data == NULL) {
- ar->ar_rrset_errno = ERRSET_NOMEMORY;
- goto fail;
+ if (rr->size != 0) {
+ rdata->rdi_data = malloc(rr->size);
+ if (rdata->rdi_data == NULL) {
+ ar->ar_rrset_errno = ERRSET_NOMEMORY;
+ goto fail;
+ }
+ memcpy(rdata->rdi_data, rr->rdata, rr->size);
}
- memcpy(rdata->rdi_data, rr->rdata, rr->size);
}
}
free_dns_response(response);
/* 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