commit 1731e3c: [Minor] Fix parsing of the very long TXT records
Vsevolod Stakhov
vsevolod at highsecure.ru
Thu Jan 6 15:07:04 UTC 2022
Author: Vsevolod Stakhov
Date: 2022-01-06 15:03:23 +0000
URL: https://github.com/rspamd/rspamd/commit/1731e3c94597f2e5797bf8dcb2197da701560a0e (HEAD -> master)
[Minor] Fix parsing of the very long TXT records
---
contrib/librdns/parse.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/contrib/librdns/parse.c b/contrib/librdns/parse.c
index 1a9c01838..e9fb85e98 100644
--- a/contrib/librdns/parse.c
+++ b/contrib/librdns/parse.c
@@ -351,10 +351,6 @@ rdns_parse_rr (struct rdns_resolver *resolver,
case DNS_T_TXT:
case DNS_T_SPF:
if (datalen <= *remain) {
- if (datalen > UINT16_MAX / 2) {
- rdns_info ("too large datalen; domain %s", rep->requested_name);
- return -1;
- }
elt->content.txt.data = malloc(datalen + 1);
if (elt->content.txt.data == NULL) {
rdns_err ("failed to allocate %d bytes for TXT record; domain %s",
@@ -417,20 +413,24 @@ rdns_parse_rr (struct rdns_resolver *resolver,
rdns_info ("stripped dns reply while reading TLSA record; domain %s", rep->requested_name);
return -1;
}
- if (datalen > UINT16_MAX / 2) {
+
+ if (datalen > *remain) {
rdns_info ("too large datalen; domain %s", rep->requested_name);
return -1;
}
+
GET8 (elt->content.tlsa.usage);
GET8 (elt->content.tlsa.selector);
GET8 (elt->content.tlsa.match_type);
datalen -= 3;
+
elt->content.tlsa.data = malloc (datalen);
if (elt->content.tlsa.data == NULL) {
rdns_err ("failed to allocate %d bytes for TLSA record; domain %s",
(int)datalen + 1, rep->requested_name);
return -1;
}
+
elt->content.tlsa.datalen = datalen;
memcpy (elt->content.tlsa.data, p, datalen);
p += datalen;
More information about the Commits
mailing list