smartdns: backport upstream fixes

This commit is contained in:
CN_SZTL 2021-01-09 21:33:41 +08:00
parent c9405b4f32
commit 059a2c9e65
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
2 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,24 @@
From 1a1347f337532ee3f53752c0c85e04edce26183d Mon Sep 17 00:00:00 2001
From: Punk <punkdm@gmail.com>
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;
}

View File

@ -0,0 +1,23 @@
From 1bb8f8887c65543ccd9f6664a23001d72fec24a6 Mon Sep 17 00:00:00 2001
From: Punk <punkdm@gmail.com>
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;
}