]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: Handle empty settings strings the same as NULLs
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 25 Jul 2023 07:14:32 +0000 (10:14 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:09 +0000 (12:34 +0200)
This will be needed by the following changes.

src/lib-http/http-client-peer.c
src/lib-http/http-client-request.c
src/lib-http/http-client.c

index b8dd824eeab2393dd39d460761af31b32f3df949..9182f55b255444bed4d97cb8908d9fbb5026abe1 100644 (file)
@@ -193,7 +193,10 @@ http_client_peer_pool_get(struct http_client_peer_shared *pshared,
 {
        struct http_client_peer_pool *ppool;
        struct ssl_iostream_context *ssl_ctx = client->ssl_ctx;
-       const char *rawlog_dir = client->set->rawlog_dir;
+       const char *rawlog_dir =
+               (client->set->rawlog_dir != NULL &&
+                client->set->rawlog_dir[0] != '\0') ?
+               client->set->rawlog_dir : NULL;
 
        i_assert(!http_client_peer_addr_is_https(&pshared->addr) ||
                 ssl_ctx != NULL);
index 7adc098661b9dcfc3b0e4da296dd420fc7e032e4..e4a5266e02890507ef9849a2a4f662fda8e9f6dd 100644 (file)
@@ -903,7 +903,8 @@ static void http_client_request_do_submit(struct http_client_request *req)
        const char *proxy_socket_path = client->set->proxy_socket_path;
        const struct http_url *proxy_url = client->set->proxy_url;
        bool have_proxy =
-               ((proxy_socket_path != NULL) || (proxy_url != NULL) ||
+               ((proxy_socket_path != NULL && proxy_socket_path[0] != '\0') ||
+                (proxy_url != NULL) ||
                 (req->host_socket != NULL) || (req->host_url != NULL));
        const char *authority, *target;
 
@@ -936,7 +937,8 @@ static void http_client_request_do_submit(struct http_client_request *req)
                        /* Tunnel to origin server */
                        req->host_url = &req->origin_url;
                        req->ssl_tunnel = TRUE;
-               } else if (proxy_socket_path != NULL) {
+               } else if (proxy_socket_path != NULL &&
+                          proxy_socket_path[0] != '\0') {
                        /* Proxy on unix socket */
                        req->host_socket = proxy_socket_path;
                        req->host_url = NULL;
@@ -1404,7 +1406,8 @@ http_client_request_send_real(struct http_client_request *req, bool pipelined)
                str_append(rtext, "\r\n");
        }
        if (http_client_request_to_proxy(req) &&
-               set->proxy_username != NULL && set->proxy_password != NULL) {
+           set->proxy_username != NULL && set->proxy_username[0] != '\0' &&
+           set->proxy_password != NULL) {
                struct http_auth_credentials auth_creds;
 
                http_auth_basic_credentials_init(&auth_creds,
@@ -1414,7 +1417,8 @@ http_client_request_send_real(struct http_client_request *req, bool pipelined)
                http_auth_create_credentials(rtext, &auth_creds);
                str_append(rtext, "\r\n");
        }
-       if (!req->have_hdr_user_agent && req->client->set->user_agent != NULL) {
+       if (!req->have_hdr_user_agent && req->client->set->user_agent != NULL &&
+           req->client->set->user_agent[0] != '\0') {
                str_printfa(rtext, "User-Agent: %s\r\n",
                            req->client->set->user_agent);
        }
index c05c109dc50e0627c8ea6840706bf992997f846f..5722d95f8dea82eb88170a2a4e2e1aef6b47f91c 100644 (file)
@@ -537,7 +537,9 @@ http_client_context_update_settings(struct http_client_context *cctx)
 
                if (cctx->dns_client == NULL)
                        cctx->dns_client = client->dns_client;
-               if (cctx->dns_client_socket_path == NULL) {
+               if (cctx->dns_client_socket_path == NULL &&
+                   client->set->dns_client_socket_path != NULL &&
+                   client->set->dns_client_socket_path[0] != '\0') {
                        cctx->dns_client_socket_path =
                                client->set->dns_client_socket_path;
                }