mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-08-06 05:47:13 +02:00
72 lines
2.5 KiB
Diff
72 lines
2.5 KiB
Diff
Adapted from https://git.exim.org/exim.git/patch/79670d3c32ccb37fe06f25d8192943b58606a32a
|
|
|
|
Reference: https://bugs.exim.org/show_bug.cgi?id=3054
|
|
--
|
|
From 79670d3c32ccb37fe06f25d8192943b58606a32a Mon Sep 17 00:00:00 2001
|
|
From: Jeremy Harris <jgh146exb@wizmail.org>
|
|
Date: Fri, 17 Nov 2023 16:55:17 +0000
|
|
Subject: [PATCH] Lookups: Fix dnsdb lookup of multi-chunk TXT. Bug 3054
|
|
|
|
Broken=by: f6b1f8e7d642
|
|
|
|
--- a/src/lookups/dnsdb.c
|
|
+++ b/src/lookups/dnsdb.c
|
|
@@ -387,38 +387,31 @@ while ((domain = string_nextinlist(&keystring, &sep, NULL, 0)))
|
|
}
|
|
|
|
/* Other kinds of record just have one piece of data each, but there may be
|
|
- several of them, of course. */
|
|
+ several of them, of course. TXT & SPF can have data in multiple chunks. */
|
|
|
|
if (yield->ptr) yield = string_catn(yield, outsep, 1);
|
|
|
|
if (type == T_TXT || type == T_SPF)
|
|
- {
|
|
- if (!outsep2) /* output only the first item of data */
|
|
+ for (unsigned data_offset = 0; data_offset + 1 < rr->size; )
|
|
{
|
|
- uschar n = (rr->data)[0];
|
|
- /* size byte + data bytes must not excced the RRs length */
|
|
- if (n + 1 <= rr->size)
|
|
- yield = string_catn(yield, US (rr->data+1), n);
|
|
+ uschar chunk_len = (rr->data)[data_offset];
|
|
+ int remain;
|
|
+
|
|
+ if (outsep2 && *outsep2 && data_offset != 0)
|
|
+ yield = string_catn(yield, outsep2, 1);
|
|
+
|
|
+ /* Apparently there are resolvers that do not check RRs before passing
|
|
+ them on, and glibc fails to do so. So every application must...
|
|
+ Check for chunk len exceeding RR */
|
|
+
|
|
+ remain = rr->size - ++data_offset;
|
|
+ if (chunk_len > remain)
|
|
+ chunk_len = remain;
|
|
+ yield = string_catn(yield, US ((rr->data) + data_offset), chunk_len);
|
|
+ data_offset += chunk_len;
|
|
+
|
|
+ if (!outsep2) break; /* output only the first chunk of the RR */
|
|
}
|
|
- else
|
|
- for (unsigned data_offset = 0; data_offset < rr->size; )
|
|
- {
|
|
- uschar chunk_len = (rr->data)[data_offset];
|
|
- int remain = rr->size - data_offset;
|
|
-
|
|
- /* Apparently there are resolvers that do not check RRs before passing
|
|
- them on, and glibc fails to do so. So every application must...
|
|
- Check for chunk len exceeding RR */
|
|
-
|
|
- if (chunk_len > remain)
|
|
- chunk_len = remain;
|
|
-
|
|
- if (*outsep2 && data_offset != 0)
|
|
- yield = string_catn(yield, outsep2, 1);
|
|
- yield = string_catn(yield, US ((rr->data) + ++data_offset), --chunk_len);
|
|
- data_offset += chunk_len;
|
|
- }
|
|
- }
|
|
else if (type == T_TLSA)
|
|
if (rr->size < 3)
|
|
continue;
|