Error: GCC_ANALYZER_WARNING (CWE-465):
dnsconfd-2.1.0-build/dnsconfd-2.1.0/src/dns_managers/unbound_manager.c: scope_hint: In function ‘get_used_servers’
dnsconfd-2.1.0-build/dnsconfd-2.1.0/src/dns_managers/unbound_manager.c:25:18: warning[-Wanalyzer-deref-before-check]: check of ‘servers’ for NULL after already dereferencing it
#   23|     unsigned char dnssec = cur_server->dnssec;
#   24|   
#   25|->   for (; servers != NULL; servers = servers->next) {
#   26|       cur_server = ((server_uri_t *)servers->data);
#   27|       if (cur_server->priority < max_priority || cur_server->protocol < max_protocol ||

Error: GCC_ANALYZER_WARNING (CWE-688):
dnsconfd-2.1.0-build/dnsconfd-2.1.0/src/dns_managers/unbound_manager.c: scope_hint: In function ‘effective_ca_from_config’
dnsconfd-2.1.0-build/dnsconfd-2.1.0/src/dns_managers/unbound_manager.c:184:12: warning[-Wanalyzer-null-argument]: use of NULL ‘effective_ca’ where non-null expected
/usr/include/glib-2.0/glib/galloca.h:35: included_from: Included from here.
/usr/include/glib-2.0/glib.h:32: included_from: Included from here.
dnsconfd-2.1.0-build/dnsconfd-2.1.0/src/dns_managers/unbound_manager.h:1: included_from: Included from here.
dnsconfd-2.1.0-build/dnsconfd-2.1.0/src/dns_managers/unbound_manager.c:1: included_from: Included from here.
/usr/include/string.h:202:14: note: argument 1 of ‘strdup’ must be non-null
#  182|     }
#  183|   
#  184|->   result = strdup(effective_ca);
#  185|   
#  186|     free(backup_ca);

Error: GCC_ANALYZER_WARNING (CWE-465):
dnsconfd-2.1.0-build/dnsconfd-2.1.0/src/dns_managers/unbound_manager.c: scope_hint: In function ‘get_forward_add_command’
dnsconfd-2.1.0-build/dnsconfd-2.1.0/src/dns_managers/unbound_manager.c:340:18: warning[-Wanalyzer-deref-before-check]: check of ‘servers’ for NULL after already dereferencing it
#  338|     g_ptr_array_add(argv_array, g_strdup(domain));
#  339|   
#  340|->   for (; servers != NULL; servers = servers->next) {
#  341|       cur_server = (server_uri_t *)servers->data;
#  342|       ip_to_str(&cur_server->address, address_buffer);

Error: GCC_ANALYZER_WARNING (CWE-775):
dnsconfd-2.1.0-build/dnsconfd-2.1.0/src/dns_managers/unbound_manager.c: scope_hint: In function ‘write_resolv_conf’
dnsconfd-2.1.0-build/dnsconfd-2.1.0/src/dns_managers/unbound_manager.c:602:13: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen(*config.resolv_conf_path, "w")’
#  600|     g_hash_table_destroy(searches_table);
#  601|   
#  602|->   if (config->resolver_options) {
#  603|       fprintf(resolv_conf_file, "options %s\n", config->resolver_options);
#  604|     }

Error: GCC_ANALYZER_WARNING (CWE-401):
dnsconfd-2.1.0-build/dnsconfd-2.1.0/src/dns_managers/unbound_manager.c:602:13: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen(*config.resolv_conf_path, "w")’
#  600|     g_hash_table_destroy(searches_table);
#  601|   
#  602|->   if (config->resolver_options) {
#  603|       fprintf(resolv_conf_file, "options %s\n", config->resolver_options);
#  604|     }

Error: GCC_ANALYZER_WARNING (CWE-775):
dnsconfd-2.1.0-build/dnsconfd-2.1.0/src/fsm/fsm.c: scope_hint: In function ‘revert_resolv_conf’
dnsconfd-2.1.0-build/dnsconfd-2.1.0/src/fsm/fsm.c:260:63: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen(*ctx_8(D)->config.resolv_conf_path, "w")’
dnsconfd-2.1.0-build/dnsconfd-2.1.0/src/fsm/fsm.c: scope_hint: In function ‘revert_resolv_conf’
#  258|     FILE *resolv_conf_file = fopen(ctx->config->resolv_conf_path, "w");
#  259|   
#  260|->   if (!resolv_conf_file || fprintf(resolv_conf_file, "%s", ctx->resolv_conf_backup->str) < 0) {
#  261|       dnsconfd_log(LOG_ERR, "Failed to revert resolv.conf");
#  262|       return EVENT_FAILURE;

Error: GCC_ANALYZER_WARNING (CWE-401):
dnsconfd-2.1.0-build/dnsconfd-2.1.0/src/fsm/fsm.c:260:63: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen(*ctx_8(D)->config.resolv_conf_path, "w")’
dnsconfd-2.1.0-build/dnsconfd-2.1.0/src/fsm/fsm.c: scope_hint: In function ‘revert_resolv_conf’
#  258|     FILE *resolv_conf_file = fopen(ctx->config->resolv_conf_path, "w");
#  259|   
#  260|->   if (!resolv_conf_file || fprintf(resolv_conf_file, "%s", ctx->resolv_conf_backup->str) < 0) {
#  261|       dnsconfd_log(LOG_ERR, "Failed to revert resolv.conf");
#  262|       return EVENT_FAILURE;

Error: CPPCHECK_WARNING (CWE-404):
dnsconfd-2.1.0-build/dnsconfd-2.1.0/src/fsm/fsm.c:265: error[resourceLeak]: Resource leak: resolv_conf_file
#  263|     }
#  264|   
#  265|->   return EVENT_SUCCESS;
#  266|   }
#  267|   

Error: CPPCHECK_WARNING (CWE-476):
dnsconfd-2.1.0-build/dnsconfd-2.1.0/unittests/test_server_uri.c:11: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: server
#    9|   static server_uri_t *create_test_server(int priority, dns_protocol_t protocol, int dnssec) {
#   10|     server_uri_t *server = calloc(1, sizeof(server_uri_t));
#   11|->   server->priority = priority;
#   12|     server->protocol = protocol;
#   13|     server->dnssec = dnssec;

Error: GCC_ANALYZER_WARNING (CWE-476):
dnsconfd-2.1.0-build/dnsconfd-2.1.0/unittests/test_server_uri.c:11:20: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘server’
dnsconfd-2.1.0-build/dnsconfd-2.1.0/unittests/test_server_uri.c:3: included_from: Included from here.
dnsconfd-2.1.0-build/dnsconfd-2.1.0/unittests/test_server_uri.c: scope_hint: In function ‘test_server_list_to_hash_table_networks_fn’
#    9|   static server_uri_t *create_test_server(int priority, dns_protocol_t protocol, int dnssec) {
#   10|     server_uri_t *server = calloc(1, sizeof(server_uri_t));
#   11|->   server->priority = priority;
#   12|     server->protocol = protocol;
#   13|     server->dnssec = dnssec;

Error: CPPCHECK_WARNING (CWE-476):
dnsconfd-2.1.0-build/dnsconfd-2.1.0/unittests/test_server_uri.c:12: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: server
#   10|     server_uri_t *server = calloc(1, sizeof(server_uri_t));
#   11|     server->priority = priority;
#   12|->   server->protocol = protocol;
#   13|     server->dnssec = dnssec;
#   14|     return server;

Error: CPPCHECK_WARNING (CWE-476):
dnsconfd-2.1.0-build/dnsconfd-2.1.0/unittests/test_server_uri.c:13: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: server
#   11|     server->priority = priority;
#   12|     server->protocol = protocol;
#   13|->   server->dnssec = dnssec;
#   14|     return server;
#   15|   }

Error: CPPCHECK_WARNING (CWE-476):
dnsconfd-2.1.0-build/dnsconfd-2.1.0/unittests/test_server_uri.c:50: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: uri
#   48|     int ret = server_uri_t_init_from_string("dns+udp://127.0.0.1:53", uri);
#   49|     ck_assert_int_eq(ret, 0);
#   50|->   ck_assert_int_eq(uri->protocol, DNS_UDP);
#   51|   
#   52|     struct sockaddr_in *s4 = (struct sockaddr_in *)&uri->address;

Error: CPPCHECK_WARNING (CWE-476):
dnsconfd-2.1.0-build/dnsconfd-2.1.0/unittests/test_unbound_manager.c:15: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: server
#   13|                                      const char *interface) {
#   14|     server_uri_t *server = calloc(1, sizeof(server_uri_t));
#   15|->   server->priority = priority;
#   16|     server->protocol = protocol;
#   17|     server->dnssec = dnssec;

Error: GCC_ANALYZER_WARNING (CWE-476):
dnsconfd-2.1.0-build/dnsconfd-2.1.0/unittests/test_unbound_manager.c:15:20: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘server’
dnsconfd-2.1.0-build/dnsconfd-2.1.0/unittests/test_unbound_manager.c: scope_hint: In function ‘test_get_used_servers_mixed_fn’
#   13|                                      const char *interface) {
#   14|     server_uri_t *server = calloc(1, sizeof(server_uri_t));
#   15|->   server->priority = priority;
#   16|     server->protocol = protocol;
#   17|     server->dnssec = dnssec;

Error: CPPCHECK_WARNING (CWE-476):
dnsconfd-2.1.0-build/dnsconfd-2.1.0/unittests/test_unbound_manager.c:16: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: server
#   14|     server_uri_t *server = calloc(1, sizeof(server_uri_t));
#   15|     server->priority = priority;
#   16|->   server->protocol = protocol;
#   17|     server->dnssec = dnssec;
#   18|     if (interface) {

Error: CPPCHECK_WARNING (CWE-476):
dnsconfd-2.1.0-build/dnsconfd-2.1.0/unittests/test_unbound_manager.c:17: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: server
#   15|     server->priority = priority;
#   16|     server->protocol = protocol;
#   17|->   server->dnssec = dnssec;
#   18|     if (interface) {
#   19|       strncpy(server->interface, interface, IFNAMSIZ - 1);

Error: CPPCHECK_WARNING (CWE-476):
dnsconfd-2.1.0-build/dnsconfd-2.1.0/unittests/test_unbound_manager.c:19: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: server
#   17|     server->dnssec = dnssec;
#   18|     if (interface) {
#   19|->     strncpy(server->interface, interface, IFNAMSIZ - 1);
#   20|     }
#   21|     return server;
