From: Stephan Bosch Date: Fri, 10 Mar 2023 03:12:20 +0000 (+0100) Subject: lib-imap-urlauth: imap-urlauth - Make sure a host name is available in imap_urlauth_c... X-Git-Tag: 2.4.0~2857 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=977dc4153d5170f92001f5cc6b0cde1cc23933a6;p=thirdparty%2Fdovecot%2Fcore.git lib-imap-urlauth: imap-urlauth - Make sure a host name is available in imap_urlauth_check_hostport(). Addresses FIXME. --- diff --git a/src/lib-imap-urlauth/imap-urlauth.c b/src/lib-imap-urlauth/imap-urlauth.c index be67fe6bc3..a83e71a883 100644 --- a/src/lib-imap-urlauth/imap-urlauth.c +++ b/src/lib-imap-urlauth/imap-urlauth.c @@ -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; }