File 2133-Fix-encode-decode-of-URI-records.patch of Package erlang
From 355eeac9bfd58ba187899ed13a11a6963c9d2b83 Mon Sep 17 00:00:00 2001
From: Raimo Niskanen <raimo@erlang.org>
Date: Tue, 10 Nov 2020 15:29:00 +0100
Subject: [PATCH 3/6] Fix encode/decode of URI records
---
lib/kernel/src/inet_dns.erl | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/lib/kernel/src/inet_dns.erl b/lib/kernel/src/inet_dns.erl
index a70f360eb9..80ce833723 100644
--- a/lib/kernel/src/inet_dns.erl
+++ b/lib/kernel/src/inet_dns.erl
@@ -484,6 +484,11 @@ decode_data(Data, _, ?S_TXT, _) ->
decode_txt(Data);
decode_data(Data, _, ?S_SPF, _) ->
decode_txt(Data);
+decode_data(<<Prio:16,Weight:16,Data0/binary>>, _, ?S_URI, _) ->
+ (1 =< byte_size(Data0))
+ orelse throw(?DECODE_ERROR),
+ Target = binary_to_list(Data0),
+ {Prio,Weight,Target};
decode_data(Data, _, ?S_URI, _) ->
decode_txt(Data);
decode_data(<<Flags:8,Data0/binary>>, _, ?S_CAA, _) ->
@@ -651,6 +656,8 @@ encode_data(Comp, Pos, ?S_NAPTR, in,
%% ?S_OPT falls through to default
encode_data(Comp, _, ?S_TXT, in, Data) -> {encode_txt(Data),Comp};
encode_data(Comp, _, ?S_SPF, in, Data) -> {encode_txt(Data),Comp};
+encode_data(Comp, _, ?S_URI, in, {Prio,Weight,Target}) ->
+ {<<Prio:16,Weight:16,(iolist_to_binary(Target))/binary>>,Comp};
encode_data(Comp, _, ?S_URI, in, Data) -> {encode_txt(Data),Comp};
encode_data(Comp, _, ?S_CAA, in, {Flags,Tag,Value}) ->
B0 = <<Flags:8>>,
--
2.26.2