]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-imap-urlauth: imap-urlauth - Make sure a host name is available in imap_urlauth_c...
authorStephan Bosch <stephan.bosch@open-xchange.com>
Fri, 10 Mar 2023 03:12:20 +0000 (04:12 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 24 Mar 2023 07:14:54 +0000 (07:14 +0000)
Addresses FIXME.

src/lib-imap-urlauth/imap-urlauth.c

index be67fe6bc3ab798a1d4f1ff4b3a916e5212d5a94..a83e71a883aa89b4065e64842f7e56296fd833cf 100644 (file)
@@ -235,17 +235,24 @@ imap_urlauth_check_hostport(struct imap_urlauth_context *uctx,
                            const struct imap_url *url,
                            const char **client_error_r)
 {
+       struct imap_url url_full = *url;
+
+       if (url_full.host.name == NULL) {
+               /* Not really supposed to happen, but we mend it anyway */
+               i_assert(url_full.host.ip.family != 0);
+               url_full.host.name = net_ip2addr(&url_full.host.ip);
+       }
+
        /* Validate host */
-       /* FIXME: allow host ip/ip6 as well? */
        if (strcmp(uctx->url_host, URL_HOST_ALLOW_ANY) != 0 &&
-           strcmp(url->host.name, uctx->url_host) != 0) {
+           strcmp(url_full.host.name, uctx->url_host) != 0) {
                *client_error_r = "Invalid URL: Inappropriate host name";
                return FALSE;
        }
 
        /* Validate port */
-       if ((url->port == 0 && uctx->url_port != 143) ||
-           (url->port != 0 && uctx->url_port != url->port)) {
+       if ((url_full.port == 0 && uctx->url_port != 143) ||
+           (url_full.port != 0 && uctx->url_port != url->port)) {
                *client_error_r = "Invalid URL: Inappropriate server port";
                return FALSE;
        }