From 452438a0afece4746156e3e114cf0d2f6992b4fa Mon Sep 17 00:00:00 2001 From: Nick Peng Date: Mon, 11 Feb 2019 00:09:12 +0800 Subject: [PATCH] Fix possible out of rage issue. --- src/dns.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/dns.c b/src/dns.c index 53780f1..50af5f9 100644 --- a/src/dns.c +++ b/src/dns.c @@ -1429,6 +1429,12 @@ static int _dns_decode_opt(struct dns_context *context, dns_rr_type type, unsign } opt_code = dns_read_short(&context->ptr); opt_len = dns_read_short(&context->ptr); + + if (_dns_left_len(context) < opt_len) { + tlog(TLOG_ERROR, "read opt data failed, opt_code = %d, opt_le = %d", opt_code, opt_len); + return -1; + } + tlog(TLOG_DEBUG, "opt type %d", opt_code); switch (opt_code) { case DNS_OPT_T_ECS: {