summaryrefslogtreecommitdiffstats
path: root/openbsd-compat/getrrsetbyname.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-26 07:43:00 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-26 07:43:00 +0000
commitc7042a16e2e4aac1030d8785c2c874d6a309b06a (patch)
tree5cc2a7944ee7d0073ecb2ae03b28fdbc4630a484 /openbsd-compat/getrrsetbyname.c
parentAdding upstream version 1:9.7p1. (diff)
downloadopenssh-c7042a16e2e4aac1030d8785c2c874d6a309b06a.tar.xz
openssh-c7042a16e2e4aac1030d8785c2c874d6a309b06a.zip
Adding upstream version 1:9.8p1.upstream/1%9.8p1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--openbsd-compat/getrrsetbyname.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/openbsd-compat/getrrsetbyname.c b/openbsd-compat/getrrsetbyname.c
index 8f59398..ad35148 100644
--- a/openbsd-compat/getrrsetbyname.c
+++ b/openbsd-compat/getrrsetbyname.c
@@ -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);
@@ -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