commit f3415ad209686ca9b0bae3e13d6b2cb64c2cb620
parent 4bbdc27dea7445bfa22af9b675b049ffc23b96b1
Author: Sebastian Nadler <sebastian.nadler@tum.de>
Date: Thu, 26 Oct 2023 11:52:59 +0200
URI RR fix
Diffstat:
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/lib/util/dnsparser.c b/src/lib/util/dnsparser.c
@@ -552,8 +552,8 @@ GNUNET_DNSPARSER_parse_uri (const char *udp_payload,
uri = GNUNET_new (struct GNUNET_DNSPARSER_UriRecord);
uri->priority = ntohs (uri_bin.prio);
uri->weight = ntohs (uri_bin.weight);
- GNUNET_asprintf(&(uri->target), "%.*s", udp_payload_length - sizeof(struct GNUNET_TUN_DnsUriRecord), &udp_payload[*off]);
- (*off) += sizeof(uri->target) + 1;
+ int len = GNUNET_asprintf(&(uri->target), "%.*s", udp_payload_length - sizeof(struct GNUNET_TUN_DnsUriRecord), &udp_payload[*off]);
+ (*off) += len;
if (NULL == uri->target) // || GNUNET_STRINGS_parse_uri(uri->target, NULL, NULL) == GNUNET_NO)
{
GNUNET_DNSPARSER_free_uri (uri);
@@ -1258,8 +1258,8 @@ GNUNET_DNSPARSER_builder_add_uri (char *dst,
sd.weight = htons (uri->weight);
GNUNET_memcpy (&dst[*off], &sd, sizeof(sd));
(*off) += sizeof(sd);
- GNUNET_memcpy(&dst[*off], uri->target, sizeof(uri->target));
- (*off) += sizeof(uri->target);
+ strncpy(&dst[*off], uri->target, dst_len - sizeof(struct GNUNET_TUN_DnsUriRecord) - 1);
+ (*off) += strlen(uri->target);
dst[*off++] = '\0';
return GNUNET_OK;
}