From 059a2c9e652d30d2a47fefd61191d9153f971e61 Mon Sep 17 00:00:00 2001 From: CN_SZTL Date: Sat, 9 Jan 2021 21:33:41 +0800 Subject: [PATCH] smartdns: backport upstream fixes --- ...r-overflow-in-the-dns_decode_opt_ecs.patch | 24 +++++++++++++++++++ ...ad-in-the_dns_decode_domain-function.patch | 23 ++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 package/ntlf9t/smartdns/patches/010-fix-a-stack-buffer-overflow-in-the-dns_decode_opt_ecs.patch create mode 100644 package/ntlf9t/smartdns/patches/020-fix-a-Out-Of-Bounds-Read-in-the_dns_decode_domain-function.patch diff --git a/package/ntlf9t/smartdns/patches/010-fix-a-stack-buffer-overflow-in-the-dns_decode_opt_ecs.patch b/package/ntlf9t/smartdns/patches/010-fix-a-stack-buffer-overflow-in-the-dns_decode_opt_ecs.patch new file mode 100644 index 0000000000..fc72b92756 --- /dev/null +++ b/package/ntlf9t/smartdns/patches/010-fix-a-stack-buffer-overflow-in-the-dns_decode_opt_ecs.patch @@ -0,0 +1,24 @@ +From 1a1347f337532ee3f53752c0c85e04edce26183d Mon Sep 17 00:00:00 2001 +From: Punk +Date: Wed, 6 Jan 2021 18:33:50 +0800 +Subject: [PATCH] fix a stack-buffer-overflow in the _dns_decode_opt_ecs() + function + +https://github.com/pymumu/smartdns/issues/670 +--- + src/dns.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/dns.c b/src/dns.c +index 0e43992..83b15dc 100644 +--- a/src/dns.c ++++ b/src/dns.c +@@ -1363,7 +1363,7 @@ static int _dns_decode_opt_ecs(struct dns_context *context, struct dns_opt_ecs * + len = (ecs->source_prefix / 8); + len += (ecs->source_prefix % 8 > 0) ? 1 : 0; + +- if (_dns_left_len(context) < len) { ++ if (_dns_left_len(context) < len || len > sizeof(ecs->addr)) { + return -1; + } + diff --git a/package/ntlf9t/smartdns/patches/020-fix-a-Out-Of-Bounds-Read-in-the_dns_decode_domain-function.patch b/package/ntlf9t/smartdns/patches/020-fix-a-Out-Of-Bounds-Read-in-the_dns_decode_domain-function.patch new file mode 100644 index 0000000000..138605da02 --- /dev/null +++ b/package/ntlf9t/smartdns/patches/020-fix-a-Out-Of-Bounds-Read-in-the_dns_decode_domain-function.patch @@ -0,0 +1,23 @@ +From 1bb8f8887c65543ccd9f6664a23001d72fec24a6 Mon Sep 17 00:00:00 2001 +From: Punk +Date: Wed, 6 Jan 2021 18:34:47 +0800 +Subject: [PATCH] fix a Out-Of-Bounds Read in the _dns_decode_domain() function + +https://github.com/pymumu/smartdns/issues/669 +--- + src/dns.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/dns.c b/src/dns.c +index 83b15dc..fa45577 100644 +--- a/src/dns.c ++++ b/src/dns.c +@@ -940,7 +940,7 @@ static int _dns_decode_domain(struct dns_context *context, char *output, int siz + + /*[len]string[len]string...[0]0 */ + while (1) { +- if (ptr > context->data + context->maxsize || ptr < context->data || output_len >= size - 1 || ptr_jump > 4) { ++ if (ptr >= context->data + context->maxsize || ptr < context->data || output_len >= size - 1 || ptr_jump > 4) { + return -1; + } +