aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2022-01-06 15:03:23 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2022-01-06 15:03:23 +0000
commit1731e3c94597f2e5797bf8dcb2197da701560a0e (patch)
treecda85fefc049b7a46f14435d5a6b6a2bdeb36baa /contrib
parentca4bb386009b2ee860db2883fa88731bfcad9db0 (diff)
downloadrspamd-1731e3c94597f2e5797bf8dcb2197da701560a0e.tar.gz
rspamd-1731e3c94597f2e5797bf8dcb2197da701560a0e.zip
[Minor] Fix parsing of the very long TXT records
Diffstat (limited to 'contrib')
-rw-r--r--contrib/librdns/parse.c10
1 files 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;