Fix possible out of rage issue.

This commit is contained in:
Nick Peng
2019-02-11 00:09:12 +08:00
parent 0085abdfdd
commit 452438a0af

View File

@@ -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: {