From: Aki Tuomi Date: Thu, 24 May 2018 17:01:43 +0000 (+0300) Subject: lib-program-client: Do not derefence set when it is NULL. X-Git-Tag: 2.3.11.2~433 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=63741ac523771a0819b7b694b700861ace22ef08;p=thirdparty%2Fdovecot%2Fcore.git lib-program-client: Do not derefence set when it is NULL. Found by coverity. Broken in 23cfbf2451f7191dee1d9995011c898a7bf32bd4 --- diff --git a/src/lib-program-client/program-client-private.h b/src/lib-program-client/program-client-private.h index 3810422345..5078388b91 100644 --- a/src/lib-program-client/program-client-private.h +++ b/src/lib-program-client/program-client-private.h @@ -74,7 +74,8 @@ void program_client_set_label(struct program_client *pclient, void program_client_init(struct program_client *pclient, pool_t pool, const char *initial_label, const char *const *args, - const struct program_client_settings *set); + const struct program_client_settings *set) + ATTR_NULL(5); void program_client_init_streams(struct program_client *pclient); diff --git a/src/lib-program-client/program-client.c b/src/lib-program-client/program-client.c index 26870500ed..289b31b683 100644 --- a/src/lib-program-client/program-client.c +++ b/src/lib-program-client/program-client.c @@ -463,20 +463,25 @@ void program_client_init(struct program_client *pclient, pool_t pool, const char *initial_label, const char *const *args, const struct program_client_settings *set) { - i_assert(set != NULL); pclient->pool = pool; if (args != NULL) pclient->args = p_strarray_dup(pool, args); - pclient->set = *set; - pclient->set.dns_client_socket_path = - p_strdup(pool, set->dns_client_socket_path); - pclient->set.home = p_strdup(pool, set->home); - pclient->debug = set->debug; pclient->fd_in = -1; pclient->fd_out = -1; - pclient->event = event_create(set->event); - event_set_forced_debug(pclient->event, set->debug); + if (set == NULL) + pclient->event = event_create(NULL); + else { + pclient->set = *set; + pclient->debug = set->debug; + pclient->set.dns_client_socket_path = + p_strdup(pool, set->dns_client_socket_path); + pclient->set.home = p_strdup(pool, set->home); + + pclient->event = event_create(set->event); + event_set_forced_debug(pclient->event, set->debug); + } + program_client_set_label(pclient, initial_label); e_debug(pclient->event, "Created"); diff --git a/src/lib-program-client/program-client.h b/src/lib-program-client/program-client.h index 0083e437d4..5d49ac59e4 100644 --- a/src/lib-program-client/program-client.h +++ b/src/lib-program-client/program-client.h @@ -33,24 +33,28 @@ struct program_client_settings { typedef void program_client_fd_callback_t(void *context, struct istream *input); typedef void program_client_callback_t(int, void *); -struct program_client *program_client_local_create(const char *bin_path, - const char *const *args, - const struct program_client_settings *set); -struct program_client *program_client_unix_create(const char *socket_path, - const char *const *args, - const struct program_client_settings *set, bool noreply); -struct program_client *program_client_net_create(const char *host, - in_port_t port, const char *const *args, - const struct program_client_settings *set, bool noreply); +struct program_client * +program_client_local_create(const char *bin_path, const char *const *args, + const struct program_client_settings *set) + ATTR_NULL(3); +struct program_client * +program_client_unix_create(const char *socket_path, const char *const *args, + const struct program_client_settings *set, + bool noreply) ATTR_NULL(3); +struct program_client * +program_client_net_create(const char *host, in_port_t port, + const char *const *args, + const struct program_client_settings *set, + bool noreply) ATTR_NULL(4); struct program_client * program_client_net_create_ips(const struct ip_addr *ips, size_t ips_count, in_port_t port, const char *const *args, const struct program_client_settings *set, - bool noreply); + bool noreply) ATTR_NULL(5); int program_client_create(const char *uri, const char *const *args, const struct program_client_settings *set, bool noreply, struct program_client **pc_r, - const char **error_r); + const char **error_r) ATTR_NULL(3); void program_client_destroy(struct program_client **_pclient);