78 lines
2.7 KiB
Diff
78 lines
2.7 KiB
Diff
|
From 061013293ceddce509ae06a31a045e803103f1ce Mon Sep 17 00:00:00 2001
|
||
|
From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemensik@redhat.com>
|
||
|
Date: Wed, 18 Aug 2021 14:59:23 +0200
|
||
|
Subject: [PATCH 02/15] Add safety checks to places pointed by Coverity
|
||
|
|
||
|
GCC Analyzer (experimental)
|
||
|
|
||
|
1. dnsmasq-2.85/src/forward.c:0: scope_hint: In function 'allocate_rfd.part.0'
|
||
|
2. dnsmasq-2.85/src/forward.c:2321:18: warning[-Wanalyzer-null-dereference]: dereference of NULL 'rfd'
|
||
|
# 2319| *fdlp = rfl;
|
||
|
# 2320|
|
||
|
# 2321|-> return rfl->rfd->fd;
|
||
|
# 2322| }
|
||
|
# 2323|
|
||
|
|
||
|
1. dnsmasq-2.85/src/cache.c:0: scope_hint: In function 'log_query'
|
||
|
2. dnsmasq-2.85/src/cache.c:1969:20: warning[-Wanalyzer-null-dereference]: dereference of NULL 'name'
|
||
|
# 1967| source = "cached";
|
||
|
# 1968|
|
||
|
# 1969|-> if (strlen(name) == 0)
|
||
|
# 1970| name = ".";
|
||
|
# 1971|
|
||
|
|
||
|
1. dnsmasq-2.85/src/cache.c:0: scope_hint: In function 'cache_scan_free'
|
||
|
2. dnsmasq-2.85/src/cache.c:436:20: warning[-Wanalyzer-null-argument]: use of NULL 'addr' where non-null expected
|
||
|
40. /usr/include/sys/un.h:37: included_from: Included from here.
|
||
|
41. dnsmasq-2.85/src/dnsmasq.h:101: included_from: Included from here.
|
||
|
42. dnsmasq-2.85/src/cache.c:17: included_from: Included from here.
|
||
|
43. /usr/include/string.h:64:12: note: argument 2 of 'memcmp' must be non-null
|
||
|
# 434| (flags & crecp->flags & F_REVERSE) &&
|
||
|
# 435| (flags & crecp->flags & (F_IPV4 | F_IPV6)) &&
|
||
|
# 436|-> memcmp(&crecp->addr, addr, addrlen) == 0)
|
||
|
# 437| {
|
||
|
# 438| *up = crecp->hash_next;
|
||
|
---
|
||
|
src/cache.c | 4 ++--
|
||
|
src/forward.c | 2 +-
|
||
|
2 files changed, 3 insertions(+), 3 deletions(-)
|
||
|
|
||
|
diff --git a/src/cache.c b/src/cache.c
|
||
|
index 8add610..97c51a7 100644
|
||
|
--- a/src/cache.c
|
||
|
+++ b/src/cache.c
|
||
|
@@ -433,7 +433,7 @@ static struct crec *cache_scan_free(char *name, union all_addr *addr, unsigned s
|
||
|
else if (!(crecp->flags & (F_HOSTS | F_DHCP | F_CONFIG)) &&
|
||
|
(flags & crecp->flags & F_REVERSE) &&
|
||
|
(flags & crecp->flags & (F_IPV4 | F_IPV6)) &&
|
||
|
- memcmp(&crecp->addr, addr, addrlen) == 0)
|
||
|
+ addr && memcmp(&crecp->addr, addr, addrlen) == 0)
|
||
|
{
|
||
|
*up = crecp->hash_next;
|
||
|
cache_unlink(crecp);
|
||
|
@@ -2013,7 +2013,7 @@ void log_query(unsigned int flags, char *name, union all_addr *addr, char *arg)
|
||
|
else
|
||
|
source = "cached";
|
||
|
|
||
|
- if (strlen(name) == 0)
|
||
|
+ if (name && !name[0])
|
||
|
name = ".";
|
||
|
|
||
|
if (option_bool(OPT_EXTRALOG))
|
||
|
diff --git a/src/forward.c b/src/forward.c
|
||
|
index 3d638e4..f07c908 100644
|
||
|
--- a/src/forward.c
|
||
|
+++ b/src/forward.c
|
||
|
@@ -2276,7 +2276,7 @@ int allocate_rfd(struct randfd_list **fdlp, struct server *serv)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
- if (j == daemon->numrrand)
|
||
|
+ if (!rfd) /* should be when j == daemon->numrrand */
|
||
|
{
|
||
|
struct randfd_list *rfl_poll;
|
||
|
|
||
|
--
|
||
|
2.31.1
|
||
|
|