Klaus Demo nginx / 0f25ed3
replace inet_addr() with ngx_inet_addr() Igor Sysoev 12 years ago
3 changed file(s) with 21 addition(s) and 25 deletion(s). Raw diff Collapse all Expand all
642642 return NGX_OK;
643643 }
644644
645 if (len++) {
646
647 p = ngx_alloc(len, pool->log);
648 if (p == NULL) {
649 return NGX_ERROR;
650 }
651
652 (void) ngx_cpystrn(p, host, len);
653
654 sin->sin_addr.s_addr = inet_addr((const char *) p);
645 if (len) {
646 sin->sin_addr.s_addr = ngx_inet_addr(host, len);
655647
656648 if (sin->sin_addr.s_addr == INADDR_NONE) {
649 p = ngx_alloc(++len, pool->log);
650 if (p == NULL) {
651 return NGX_ERROR;
652 }
653
654 (void) ngx_cpystrn(p, host, len);
655
657656 h = gethostbyname((const char *) p);
657
658 ngx_free(p);
658659
659660 if (h == NULL || h->h_addr_list[0] == NULL) {
660661 ngx_free(p);
668669 if (sin->sin_addr.s_addr == INADDR_ANY) {
669670 u->wildcard = 1;
670671 }
671
672 ngx_free(p);
673672
674673 } else {
675674 sin->sin_addr.s_addr = INADDR_ANY;
814813 struct hostent *h;
815814 struct sockaddr_in *sin;
816815
817 host = ngx_alloc(u->host.len + 1, pool->log);
818 if (host == NULL) {
819 return NGX_ERROR;
820 }
821
822 (void) ngx_cpystrn(host, u->host.data, u->host.len + 1);
823
824816 /* AF_INET only */
825817
826818 port = htons(u->port);
827819
828 in_addr = inet_addr((char *) host);
820 in_addr = ngx_inet_addr(u->host.data, u->host.len);
829821
830822 if (in_addr == INADDR_NONE) {
823 host = ngx_alloc(u->host.len + 1, pool->log);
824 if (host == NULL) {
825 return NGX_ERROR;
826 }
827
828 (void) ngx_cpystrn(host, u->host.data, u->host.len + 1);
829
831830 h = gethostbyname((char *) host);
832831
833832 ngx_free(host);
882881
883882 } else {
884883
885 ngx_free(host);
886
887884 /* MP: ngx_shared_palloc() */
888885
889886 u->addrs = ngx_pcalloc(pool, sizeof(ngx_peer_addr_t));
225225
226226 ngx_http_set_ctx(r, ctx, ngx_http_realip_module);
227227
228 addr = inet_addr((char *) ip);
228 addr = ngx_inet_addr(ip, len);
229229
230230 if (addr == INADDR_NONE) {
231231 return NGX_DECLINED;
794794
795795 sin->sin_port = htons((in_port_t) port);
796796
797 ctx->addr.data[ctx->addr.len] = '\0';
798 sin->sin_addr.s_addr = inet_addr((char *) ctx->addr.data);
797 sin->sin_addr.s_addr = ngx_inet_addr(ctx->addr.data, ctx->addr.len);
799798 if (sin->sin_addr.s_addr == INADDR_NONE) {
800799 ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
801800 "auth http server %V sent invalid server "