Skip to content

Commit

Permalink
asan: fix some bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
pymumu committed Jul 18, 2024
1 parent 550d455 commit 655da27
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 23 deletions.
1 change: 1 addition & 0 deletions src/dns_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ struct client_dns_server_flag_udp {
};

struct client_dns_server_flag_mdns {
int padding;
};

struct client_dns_server_flag_tls {
Expand Down
2 changes: 0 additions & 2 deletions src/dns_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -3024,7 +3024,6 @@ static int _config_bind_ip(int argc, char *argv[], DNS_BIND_TYPE type)
struct dns_bind_ip *bind_ip = NULL;
char *ip = NULL;
int opt = 0;
int optind = 0;
int optind_last = 0;
char group_name[DNS_GROUP_NAME_LEN];
const char *group = NULL;
Expand Down Expand Up @@ -4841,7 +4840,6 @@ static int _conf_domain_rule_no_ipalias(const char *domain)
static int _conf_domain_rules(void *data, int argc, char *argv[])
{
int opt = 0;
int optind = 0;
int optind_last = 0;
char domain[DNS_MAX_CONF_CNAME_LEN];
char *value = argv[1];
Expand Down
42 changes: 24 additions & 18 deletions src/dns_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -3582,26 +3582,29 @@ static int _dns_server_ip_rule_check(struct dns_request *request, struct dns_ip_
goto rule_not_found;
}

rule_flags = container_of(ip_rules->rules[IP_RULE_FLAGS], struct ip_rule_flags, head);
if (rule_flags != NULL) {
if (rule_flags->flags & IP_RULE_FLAG_BOGUS) {
request->rcode = DNS_RC_NXDOMAIN;
request->has_soa = 1;
request->force_soa = 1;
_dns_server_setup_soa(request);
goto nxdomain;
}
struct dns_ip_rule *rule = ip_rules->rules[IP_RULE_FLAGS];
if (rule != NULL) {
rule_flags = container_of(rule, struct ip_rule_flags, head);
if (rule_flags != NULL) {
if (rule_flags->flags & IP_RULE_FLAG_BOGUS) {
request->rcode = DNS_RC_NXDOMAIN;
request->has_soa = 1;
request->force_soa = 1;
_dns_server_setup_soa(request);
goto nxdomain;
}

/* blacklist-ip */
if (rule_flags->flags & IP_RULE_FLAG_BLACKLIST) {
if (result_flag & DNSSERVER_FLAG_BLACKLIST_IP) {
goto match;
/* blacklist-ip */
if (rule_flags->flags & IP_RULE_FLAG_BLACKLIST) {
if (result_flag & DNSSERVER_FLAG_BLACKLIST_IP) {
goto match;
}
}
}

/* ignore-ip */
if (rule_flags->flags & IP_RULE_FLAG_IP_IGNORE) {
goto skip;
/* ignore-ip */
if (rule_flags->flags & IP_RULE_FLAG_IP_IGNORE) {
goto skip;
}
}
}

Expand Down Expand Up @@ -4373,7 +4376,10 @@ static int _dns_server_get_answer(struct dns_server_post_context *context)
continue;
}

_dns_server_context_add_ip(context, addr_map->ip_addr);
if (addr_map != NULL) {
_dns_server_context_add_ip(context, addr_map->ip_addr);
}

if (request->has_ip == 1) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ int netlink_get_neighbors(int family,
continue;
}

int nlh_len = len;
uint32_t nlh_len = len;
for (nlh = (struct nlmsghdr *)buf; NLMSG_OK(nlh, nlh_len); nlh = NLMSG_NEXT(nlh, nlh_len)) {
ndm = NLMSG_DATA(nlh);
struct rtattr *rta = RTM_RTA(ndm);
Expand Down
2 changes: 1 addition & 1 deletion test/cases/test-subnet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ TEST_F(SubNet, per_server)
return smartdns::SERVER_REQUEST_OK;
}

if (request->qtype = DNS_T_AAAA) {
if (request->qtype == DNS_T_AAAA) {
struct dns_opt_ecs ecs;
struct dns_rrs *rrs = NULL;
int rr_count = 0;
Expand Down
3 changes: 2 additions & 1 deletion test/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void MockServer::Stop()

if (fd_ > 0) {
close(fd_);
fd_;
fd_ = -1;;
}
}

Expand Down Expand Up @@ -229,6 +229,7 @@ bool MockServer::GetAddr(const std::string &host, const std::string port, int ty

memcpy(addr, result->ai_addr, result->ai_addrlen);
*addrlen = result->ai_addrlen;
freeaddrinfo(result);
return true;
errout:
if (result) {
Expand Down

0 comments on commit 655da27

Please sign in to comment.