]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-program-client: Do not derefence set when it is NULL.
authorAki Tuomi <aki.tuomi@dovecot.fi>
Thu, 24 May 2018 17:01:43 +0000 (20:01 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Wed, 15 Apr 2020 08:59:23 +0000 (08:59 +0000)
Found by coverity. Broken in 23cfbf2451f7191dee1d9995011c898a7bf32bd4

src/lib-program-client/program-client-private.h
src/lib-program-client/program-client.c
src/lib-program-client/program-client.h

index 381042234503e47e4701e84a8d393def684f179a..5078388b919777b4efae514811d3fcd295e233a9 100644 (file)
@@ -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);
 
index 26870500edb6e8439ae40e390c77b436c7ee571e..289b31b683f126fae93e6ab6200e0d9adb84b0c1 100644 (file)
@@ -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");
index 0083e437d4b3ac7cc6793a1de63f8236fef74567..5d49ac59e4b1040c9124d0af3abaa1d45cf439ac 100644 (file)
@@ -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);