src/http/ngx_http_core_module.c:4113: error: Integer Overflow L2
  ([0, +oo] - 2):unsigned64 by call to `ngx_http_add_listen`.

src/http/ngx_http_core_module.c:3787:9: Call
3785.     u.default_port = 80;
3786. 
3787.     if (ngx_parse_url(cf->pool, &u) != NGX_OK) {
              ^
3788.         if (u.err) {
3789.             ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,

src/core/ngx_inet.c:693:16: Call
  691. 
  692.     if (len >= 5 && ngx_strncasecmp(p, (u_char *) "unix:", 5) == 0) {
  693.         return ngx_parse_unix_domain_url(pool, u);
                      ^
  694.     }
  695. 

src/core/ngx_inet.c:766:5: Assignment
    764. 
    765.     u->addrs[0].sockaddr = (struct sockaddr *) saun;
    766.     u->addrs[0].socklen = sizeof(struct sockaddr_un);
             ^
    767.     u->addrs[0].name.len = len + 4;
    768.     u->addrs[0].name.data = u->url.data;

src/http/ngx_http_core_module.c:4109:9: Assignment
4107.     for (n = 0; n < u.naddrs; n++) {
4108.         lsopt.sockaddr = u.addrs[n].sockaddr;
4109.         lsopt.socklen = u.addrs[n].socklen;
              ^
4110.         lsopt.addr_text = u.addrs[n].name;
4111.         lsopt.wildcard = ngx_inet_wildcard(lsopt.sockaddr);

src/http/ngx_http_core_module.c:4113:13: Call
4111.         lsopt.wildcard = ngx_inet_wildcard(lsopt.sockaddr);
4112. 
4113.         if (ngx_http_add_listen(cf, cscf, &lsopt) != NGX_OK) {
                  ^
4114.             return NGX_CONF_ERROR;
4115.         }

src/http/ngx_http.c:1140:1: Parameter `lsopt->socklen`
  1138. 
  1139. 
  1140. ngx_int_t
        ^
  1141. ngx_http_add_listen(ngx_conf_t *cf, ngx_http_core_srv_conf_t *cscf,
  1142.     ngx_http_listen_opt_t *lsopt)

src/http/ngx_http.c:1172:16: Call
  1170.         /* a port is already in the port list */
  1171. 
  1172.         return ngx_http_add_addresses(cf, cscf, &port[i], lsopt);
                       ^
  1173.     }
  1174. 

src/http/ngx_http.c:1190:1: Parameter `lsopt->socklen`
    1188. 
    1189. 
    1190. static ngx_int_t
          ^
    1191. ngx_http_add_addresses(ngx_conf_t *cf, ngx_http_core_srv_conf_t *cscf,
    1192.     ngx_http_conf_port_t *port, ngx_http_listen_opt_t *lsopt)

src/http/ngx_http.c:1212:13: Call
    1210.     for (i = 0; i < port->addrs.nelts; i++) {
    1211. 
    1212.         if (ngx_cmp_sockaddr(lsopt->sockaddr, lsopt->socklen,
                      ^
    1213.                              addr[i].opt.sockaddr,
    1214.                              addr[i].opt.socklen, 0)

src/core/ngx_inet.c:1323:1: <LHS trace>
1321. 
1322. 
1323. ngx_int_t
      ^
1324. ngx_cmp_sockaddr(struct sockaddr *sa1, socklen_t slen1,
1325.     struct sockaddr *sa2, socklen_t slen2, ngx_uint_t cmp_port)

src/core/ngx_inet.c:1323:1: Parameter `slen2`
      1321. 
      1322. 
      1323. ngx_int_t
            ^
      1324. ngx_cmp_sockaddr(struct sockaddr *sa1, socklen_t slen1,
      1325.     struct sockaddr *sa2, socklen_t slen2, ngx_uint_t cmp_port)

src/core/ngx_inet.c:1366:13: Binary operation: ([0, +oo] - 2):unsigned64 by call to `ngx_http_add_listen` 
      1364. 
      1365.         if (slen1 < slen2) {
      1366.             len = slen1 - offsetof(struct sockaddr_un, sun_path);
                        ^
      1367. 
      1368.         } else {

ngx_int_t
ngx_cmp_sockaddr(struct sockaddr *sa1, socklen_t slen1,
    struct sockaddr *sa2, socklen_t slen2, ngx_uint_t cmp_port)
{
    struct sockaddr_in   *sin1, *sin2;
#if (NGX_HAVE_INET6)
    struct sockaddr_in6  *sin61, *sin62;
#endif
#if (NGX_HAVE_UNIX_DOMAIN)
    size_t                len;
    struct sockaddr_un   *saun1, *saun2;
#endif
    if (sa1->sa_family != sa2->sa_family) {
        return NGX_DECLINED;
    }
    switch (sa1->sa_family) {
#if (NGX_HAVE_INET6)
    case AF_INET6:
        sin61 = (struct sockaddr_in6 *) sa1;
        sin62 = (struct sockaddr_in6 *) sa2;
        if (cmp_port && sin61->sin6_port != sin62->sin6_port) {
            return NGX_DECLINED;
        }
        if (ngx_memcmp(&sin61->sin6_addr, &sin62->sin6_addr, 16) != 0) {
            return NGX_DECLINED;
        }
        break;
#endif
#if (NGX_HAVE_UNIX_DOMAIN)
    case AF_UNIX:
        saun1 = (struct sockaddr_un *) sa1;
        saun2 = (struct sockaddr_un *) sa2;
        if (slen1 < slen2) {
            len = slen1 - offsetof(struct sockaddr_un, sun_path);
        } else {
            len = slen2 - offsetof(struct sockaddr_un, sun_path);
        }
        if (len > sizeof(saun1->sun_path)) {
            len = sizeof(saun1->sun_path);
        }
        if (ngx_memcmp(&saun1->sun_path, &saun2->sun_path, len) != 0) {
            return NGX_DECLINED;
        }
        break;
#endif
    default:
        sin1 = (struct sockaddr_in *) sa1;
        sin2 = (struct sockaddr_in *) sa2;
        if (cmp_port && sin1->sin_port != sin2->sin_port) {
            return NGX_DECLINED;
        }
        if (sin1->sin_addr.s_addr != sin2->sin_addr.s_addr) {
            return NGX_DECLINED;
        }
        break;
    }
    return NGX_OK;
}
['static char *\nngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)\n{\n    ngx_http_core_srv_conf_t *cscf = conf;\n    ngx_str_t              *value, size;\n    ngx_url_t               u;\n    ngx_uint_t              n;\n    ngx_http_listen_opt_t   lsopt;\n    cscf->listen = 1;\n    value = cf->args->elts;\n    ngx_memzero(&u, sizeof(ngx_url_t));\n    u.url = value[1];\n    u.listen = 1;\n    u.default_port = 80;\n    if (ngx_parse_url(cf->pool, &u) != NGX_OK) {\n        if (u.err) {\n            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                               "%s in \\"%V\\" of the \\"listen\\" directive",\n                               u.err, &u.url);\n        }\n        return NGX_CONF_ERROR;\n    }\n    ngx_memzero(&lsopt, sizeof(ngx_http_listen_opt_t));\n    lsopt.backlog = NGX_LISTEN_BACKLOG;\n    lsopt.rcvbuf = -1;\n    lsopt.sndbuf = -1;\n#if (NGX_HAVE_SETFIB)\n    lsopt.setfib = -1;\n#endif\n#if (NGX_HAVE_TCP_FASTOPEN)\n    lsopt.fastopen = -1;\n#endif\n#if (NGX_HAVE_INET6)\n    lsopt.ipv6only = 1;\n#endif\n    for (n = 2; n < cf->args->nelts; n++) {\n        if (ngx_strcmp(value[n].data, "default_server") == 0\n            || ngx_strcmp(value[n].data, "default") == 0)\n        {\n            lsopt.default_server = 1;\n            continue;\n        }\n        if (ngx_strcmp(value[n].data, "bind") == 0) {\n            lsopt.set = 1;\n            lsopt.bind = 1;\n            continue;\n        }\n#if (NGX_HAVE_SETFIB)\n        if (ngx_strncmp(value[n].data, "setfib=", 7) == 0) {\n            lsopt.setfib = ngx_atoi(value[n].data + 7, value[n].len - 7);\n            lsopt.set = 1;\n            lsopt.bind = 1;\n            if (lsopt.setfib == NGX_ERROR) {\n                ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                                   "invalid setfib \\"%V\\"", &value[n]);\n                return NGX_CONF_ERROR;\n            }\n            continue;\n        }\n#endif\n#if (NGX_HAVE_TCP_FASTOPEN)\n        if (ngx_strncmp(value[n].data, "fastopen=", 9) == 0) {\n            lsopt.fastopen = ngx_atoi(value[n].data + 9, value[n].len - 9);\n            lsopt.set = 1;\n            lsopt.bind = 1;\n            if (lsopt.fastopen == NGX_ERROR) {\n                ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                                   "invalid fastopen \\"%V\\"", &value[n]);\n                return NGX_CONF_ERROR;\n            }\n            continue;\n        }\n#endif\n        if (ngx_strncmp(value[n].data, "backlog=", 8) == 0) {\n            lsopt.backlog = ngx_atoi(value[n].data + 8, value[n].len - 8);\n            lsopt.set = 1;\n            lsopt.bind = 1;\n            if (lsopt.backlog == NGX_ERROR || lsopt.backlog == 0) {\n                ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                                   "invalid backlog \\"%V\\"", &value[n]);\n                return NGX_CONF_ERROR;\n            }\n            continue;\n        }\n        if (ngx_strncmp(value[n].data, "rcvbuf=", 7) == 0) {\n            size.len = value[n].len - 7;\n            size.data = value[n].data + 7;\n            lsopt.rcvbuf = ngx_parse_size(&size);\n            lsopt.set = 1;\n            lsopt.bind = 1;\n            if (lsopt.rcvbuf == NGX_ERROR) {\n                ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                                   "invalid rcvbuf \\"%V\\"", &value[n]);\n                return NGX_CONF_ERROR;\n            }\n            continue;\n        }\n        if (ngx_strncmp(value[n].data, "sndbuf=", 7) == 0) {\n            size.len = value[n].len - 7;\n            size.data = value[n].data + 7;\n            lsopt.sndbuf = ngx_parse_size(&size);\n            lsopt.set = 1;\n            lsopt.bind = 1;\n            if (lsopt.sndbuf == NGX_ERROR) {\n                ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                                   "invalid sndbuf \\"%V\\"", &value[n]);\n                return NGX_CONF_ERROR;\n            }\n            continue;\n        }\n        if (ngx_strncmp(value[n].data, "accept_filter=", 14) == 0) {\n#if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)\n            lsopt.accept_filter = (char *) &value[n].data[14];\n            lsopt.set = 1;\n            lsopt.bind = 1;\n#else\n            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                               "accept filters \\"%V\\" are not supported "\n                               "on this platform, ignored",\n                               &value[n]);\n#endif\n            continue;\n        }\n        if (ngx_strcmp(value[n].data, "deferred") == 0) {\n#if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)\n            lsopt.deferred_accept = 1;\n            lsopt.set = 1;\n            lsopt.bind = 1;\n#else\n            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                               "the deferred accept is not supported "\n                               "on this platform, ignored");\n#endif\n            continue;\n        }\n        if (ngx_strncmp(value[n].data, "ipv6only=o", 10) == 0) {\n#if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)\n            if (ngx_strcmp(&value[n].data[10], "n") == 0) {\n                lsopt.ipv6only = 1;\n            } else if (ngx_strcmp(&value[n].data[10], "ff") == 0) {\n                lsopt.ipv6only = 0;\n            } else {\n                ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                                   "invalid ipv6only flags \\"%s\\"",\n                                   &value[n].data[9]);\n                return NGX_CONF_ERROR;\n            }\n            lsopt.set = 1;\n            lsopt.bind = 1;\n            continue;\n#else\n            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                               "ipv6only is not supported "\n                               "on this platform");\n            return NGX_CONF_ERROR;\n#endif\n        }\n        if (ngx_strcmp(value[n].data, "reuseport") == 0) {\n#if (NGX_HAVE_REUSEPORT)\n            lsopt.reuseport = 1;\n            lsopt.set = 1;\n            lsopt.bind = 1;\n#else\n            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                               "reuseport is not supported "\n                               "on this platform, ignored");\n#endif\n            continue;\n        }\n        if (ngx_strcmp(value[n].data, "ssl") == 0) {\n#if (NGX_HTTP_SSL)\n            lsopt.ssl = 1;\n            continue;\n#else\n            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                               "the \\"ssl\\" parameter requires "\n                               "ngx_http_ssl_module");\n            return NGX_CONF_ERROR;\n#endif\n        }\n        if (ngx_strcmp(value[n].data, "http2") == 0) {\n#if (NGX_HTTP_V2)\n            lsopt.http2 = 1;\n            continue;\n#else\n            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                               "the \\"http2\\" parameter requires "\n                               "ngx_http_v2_module");\n            return NGX_CONF_ERROR;\n#endif\n        }\n        if (ngx_strcmp(value[n].data, "spdy") == 0) {\n            ngx_conf_log_error(NGX_LOG_WARN, cf, 0,\n                               "invalid parameter \\"spdy\\": "\n                               "ngx_http_spdy_module was superseded "\n                               "by ngx_http_v2_module");\n            continue;\n        }\n        if (ngx_strncmp(value[n].data, "so_keepalive=", 13) == 0) {\n            if (ngx_strcmp(&value[n].data[13], "on") == 0) {\n                lsopt.so_keepalive = 1;\n            } else if (ngx_strcmp(&value[n].data[13], "off") == 0) {\n                lsopt.so_keepalive = 2;\n            } else {\n#if (NGX_HAVE_KEEPALIVE_TUNABLE)\n                u_char     *p, *end;\n                ngx_str_t   s;\n                end = value[n].data + value[n].len;\n                s.data = value[n].data + 13;\n                p = ngx_strlchr(s.data, end, \':\');\n                if (p == NULL) {\n                    p = end;\n                }\n                if (p > s.data) {\n                    s.len = p - s.data;\n                    lsopt.tcp_keepidle = ngx_parse_time(&s, 1);\n                    if (lsopt.tcp_keepidle == (time_t) NGX_ERROR) {\n                        goto invalid_so_keepalive;\n                    }\n                }\n                s.data = (p < end) ? (p + 1) : end;\n                p = ngx_strlchr(s.data, end, \':\');\n                if (p == NULL) {\n                    p = end;\n                }\n                if (p > s.data) {\n                    s.len = p - s.data;\n                    lsopt.tcp_keepintvl = ngx_parse_time(&s, 1);\n                    if (lsopt.tcp_keepintvl == (time_t) NGX_ERROR) {\n                        goto invalid_so_keepalive;\n                    }\n                }\n                s.data = (p < end) ? (p + 1) : end;\n                if (s.data < end) {\n                    s.len = end - s.data;\n                    lsopt.tcp_keepcnt = ngx_atoi(s.data, s.len);\n                    if (lsopt.tcp_keepcnt == NGX_ERROR) {\n                        goto invalid_so_keepalive;\n                    }\n                }\n                if (lsopt.tcp_keepidle == 0 && lsopt.tcp_keepintvl == 0\n                    && lsopt.tcp_keepcnt == 0)\n                {\n                    goto invalid_so_keepalive;\n                }\n                lsopt.so_keepalive = 1;\n#else\n                ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                                   "the \\"so_keepalive\\" parameter accepts "\n                                   "only \\"on\\" or \\"off\\" on this platform");\n                return NGX_CONF_ERROR;\n#endif\n            }\n            lsopt.set = 1;\n            lsopt.bind = 1;\n            continue;\n#if (NGX_HAVE_KEEPALIVE_TUNABLE)\n        invalid_so_keepalive:\n            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                               "invalid so_keepalive value: \\"%s\\"",\n                               &value[n].data[13]);\n            return NGX_CONF_ERROR;\n#endif\n        }\n        if (ngx_strcmp(value[n].data, "proxy_protocol") == 0) {\n            lsopt.proxy_protocol = 1;\n            continue;\n        }\n        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                           "invalid parameter \\"%V\\"", &value[n]);\n        return NGX_CONF_ERROR;\n    }\n    for (n = 0; n < u.naddrs; n++) {\n        lsopt.sockaddr = u.addrs[n].sockaddr;\n        lsopt.socklen = u.addrs[n].socklen;\n        lsopt.addr_text = u.addrs[n].name;\n        lsopt.wildcard = ngx_inet_wildcard(lsopt.sockaddr);\n        if (ngx_http_add_listen(cf, cscf, &lsopt) != NGX_OK) {\n            return NGX_CONF_ERROR;\n        }\n    }\n    return NGX_CONF_OK;\n}', 'ngx_int_t\nngx_parse_url(ngx_pool_t *pool, ngx_url_t *u)\n{\n    u_char  *p;\n    size_t   len;\n    p = u->url.data;\n    len = u->url.len;\n    if (len >= 5 && ngx_strncasecmp(p, (u_char *) "unix:", 5) == 0) {\n        return ngx_parse_unix_domain_url(pool, u);\n    }\n    if (len && p[0] == \'[\') {\n        return ngx_parse_inet6_url(pool, u);\n    }\n    return ngx_parse_inet_url(pool, u);\n}', 'static ngx_int_t\nngx_parse_unix_domain_url(ngx_pool_t *pool, ngx_url_t *u)\n{\n#if (NGX_HAVE_UNIX_DOMAIN)\n    u_char              *path, *uri, *last;\n    size_t               len;\n    struct sockaddr_un  *saun;\n    len = u->url.len;\n    path = u->url.data;\n    path += 5;\n    len -= 5;\n    if (u->uri_part) {\n        last = path + len;\n        uri = ngx_strlchr(path, last, \':\');\n        if (uri) {\n            len = uri - path;\n            uri++;\n            u->uri.len = last - uri;\n            u->uri.data = uri;\n        }\n    }\n    if (len == 0) {\n        u->err = "no path in the unix domain socket";\n        return NGX_ERROR;\n    }\n    u->host.len = len++;\n    u->host.data = path;\n    if (len > sizeof(saun->sun_path)) {\n        u->err = "too long path in the unix domain socket";\n        return NGX_ERROR;\n    }\n    u->socklen = sizeof(struct sockaddr_un);\n    saun = (struct sockaddr_un *) &u->sockaddr;\n    saun->sun_family = AF_UNIX;\n    (void) ngx_cpystrn((u_char *) saun->sun_path, path, len);\n    u->addrs = ngx_pcalloc(pool, sizeof(ngx_addr_t));\n    if (u->addrs == NULL) {\n        return NGX_ERROR;\n    }\n    saun = ngx_pcalloc(pool, sizeof(struct sockaddr_un));\n    if (saun == NULL) {\n        return NGX_ERROR;\n    }\n    u->family = AF_UNIX;\n    u->naddrs = 1;\n    saun->sun_family = AF_UNIX;\n    (void) ngx_cpystrn((u_char *) saun->sun_path, path, len);\n    u->addrs[0].sockaddr = (struct sockaddr *) saun;\n    u->addrs[0].socklen = sizeof(struct sockaddr_un);\n    u->addrs[0].name.len = len + 4;\n    u->addrs[0].name.data = u->url.data;\n    return NGX_OK;\n#else\n    u->err = "the unix domain sockets are not supported on this platform";\n    return NGX_ERROR;\n#endif\n}', 'ngx_int_t\nngx_http_add_listen(ngx_conf_t *cf, ngx_http_core_srv_conf_t *cscf,\n    ngx_http_listen_opt_t *lsopt)\n{\n    in_port_t                   p;\n    ngx_uint_t                  i;\n    struct sockaddr            *sa;\n    ngx_http_conf_port_t       *port;\n    ngx_http_core_main_conf_t  *cmcf;\n    cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);\n    if (cmcf->ports == NULL) {\n        cmcf->ports = ngx_array_create(cf->temp_pool, 2,\n                                       sizeof(ngx_http_conf_port_t));\n        if (cmcf->ports == NULL) {\n            return NGX_ERROR;\n        }\n    }\n    sa = lsopt->sockaddr;\n    p = ngx_inet_get_port(sa);\n    port = cmcf->ports->elts;\n    for (i = 0; i < cmcf->ports->nelts; i++) {\n        if (p != port[i].port || sa->sa_family != port[i].family) {\n            continue;\n        }\n        return ngx_http_add_addresses(cf, cscf, &port[i], lsopt);\n    }\n    port = ngx_array_push(cmcf->ports);\n    if (port == NULL) {\n        return NGX_ERROR;\n    }\n    port->family = sa->sa_family;\n    port->port = p;\n    port->addrs.elts = NULL;\n    return ngx_http_add_address(cf, cscf, port, lsopt);\n}', 'static ngx_int_t\nngx_http_add_addresses(ngx_conf_t *cf, ngx_http_core_srv_conf_t *cscf,\n    ngx_http_conf_port_t *port, ngx_http_listen_opt_t *lsopt)\n{\n    ngx_uint_t             i, default_server, proxy_protocol;\n    ngx_http_conf_addr_t  *addr;\n#if (NGX_HTTP_SSL)\n    ngx_uint_t             ssl;\n#endif\n#if (NGX_HTTP_V2)\n    ngx_uint_t             http2;\n#endif\n    addr = port->addrs.elts;\n    for (i = 0; i < port->addrs.nelts; i++) {\n        if (ngx_cmp_sockaddr(lsopt->sockaddr, lsopt->socklen,\n                             addr[i].opt.sockaddr,\n                             addr[i].opt.socklen, 0)\n            != NGX_OK)\n        {\n            continue;\n        }\n        if (ngx_http_add_server(cf, cscf, &addr[i]) != NGX_OK) {\n            return NGX_ERROR;\n        }\n        default_server = addr[i].opt.default_server;\n        proxy_protocol = lsopt->proxy_protocol || addr[i].opt.proxy_protocol;\n#if (NGX_HTTP_SSL)\n        ssl = lsopt->ssl || addr[i].opt.ssl;\n#endif\n#if (NGX_HTTP_V2)\n        http2 = lsopt->http2 || addr[i].opt.http2;\n#endif\n        if (lsopt->set) {\n            if (addr[i].opt.set) {\n                ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                                   "duplicate listen options for %V",\n                                   &addr[i].opt.addr_text);\n                return NGX_ERROR;\n            }\n            addr[i].opt = *lsopt;\n        }\n        if (lsopt->default_server) {\n            if (default_server) {\n                ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                                   "a duplicate default server for %V",\n                                   &addr[i].opt.addr_text);\n                return NGX_ERROR;\n            }\n            default_server = 1;\n            addr[i].default_server = cscf;\n        }\n        addr[i].opt.default_server = default_server;\n        addr[i].opt.proxy_protocol = proxy_protocol;\n#if (NGX_HTTP_SSL)\n        addr[i].opt.ssl = ssl;\n#endif\n#if (NGX_HTTP_V2)\n        addr[i].opt.http2 = http2;\n#endif\n        return NGX_OK;\n    }\n    return ngx_http_add_address(cf, cscf, port, lsopt);\n}', 'ngx_int_t\nngx_cmp_sockaddr(struct sockaddr *sa1, socklen_t slen1,\n    struct sockaddr *sa2, socklen_t slen2, ngx_uint_t cmp_port)\n{\n    struct sockaddr_in   *sin1, *sin2;\n#if (NGX_HAVE_INET6)\n    struct sockaddr_in6  *sin61, *sin62;\n#endif\n#if (NGX_HAVE_UNIX_DOMAIN)\n    size_t                len;\n    struct sockaddr_un   *saun1, *saun2;\n#endif\n    if (sa1->sa_family != sa2->sa_family) {\n        return NGX_DECLINED;\n    }\n    switch (sa1->sa_family) {\n#if (NGX_HAVE_INET6)\n    case AF_INET6:\n        sin61 = (struct sockaddr_in6 *) sa1;\n        sin62 = (struct sockaddr_in6 *) sa2;\n        if (cmp_port && sin61->sin6_port != sin62->sin6_port) {\n            return NGX_DECLINED;\n        }\n        if (ngx_memcmp(&sin61->sin6_addr, &sin62->sin6_addr, 16) != 0) {\n            return NGX_DECLINED;\n        }\n        break;\n#endif\n#if (NGX_HAVE_UNIX_DOMAIN)\n    case AF_UNIX:\n        saun1 = (struct sockaddr_un *) sa1;\n        saun2 = (struct sockaddr_un *) sa2;\n        if (slen1 < slen2) {\n            len = slen1 - offsetof(struct sockaddr_un, sun_path);\n        } else {\n            len = slen2 - offsetof(struct sockaddr_un, sun_path);\n        }\n        if (len > sizeof(saun1->sun_path)) {\n            len = sizeof(saun1->sun_path);\n        }\n        if (ngx_memcmp(&saun1->sun_path, &saun2->sun_path, len) != 0) {\n            return NGX_DECLINED;\n        }\n        break;\n#endif\n    default:\n        sin1 = (struct sockaddr_in *) sa1;\n        sin2 = (struct sockaddr_in *) sa2;\n        if (cmp_port && sin1->sin_port != sin2->sin_port) {\n            return NGX_DECLINED;\n        }\n        if (sin1->sin_addr.s_addr != sin2->sin_addr.s_addr) {\n            return NGX_DECLINED;\n        }\n        break;\n    }\n    return NGX_OK;\n}']