chaizhenhua / ngx-ip2location

Nginx IP2Location Module
BSD 2-Clause "Simplified" License
23 stars 19 forks source link

debian nginx repack error with ngx_sock #3

Closed tobsn closed 9 years ago

tobsn commented 9 years ago
cc -c -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2  -I src/core -I src/event -I src/event/modules -I src/os/unix -I /usr/include/libxml2 -I objs -I src/http -I src/http/modules -I src/mail \
        -o objs/addon/ngx-ip2location-master/ngx_http_ip2location.o \
        /home/admin/test/ngx-ip2location-master/ngx_http_ip2location.c
/home/admin/test/ngx-ip2location-master/ngx_http_ip2location.c: In function ‘ngx_http_ip2location_create_ctx’:
/home/admin/test/ngx-ip2location-master/ngx_http_ip2location.c:468:5: warning: passing argument 2 of ‘ngx_sock_ntop’ makes integer from pointer without a cast [enabled by default]
In file included from src/core/ngx_core.h:69:0,
                 from src/http/ngx_http.h:13,
                 from /home/admin/test/ngx-ip2location-master/ngx_http_ip2location.c:7:
src/core/ngx_inet.h:110:8: note: expected ‘socklen_t’ but argument is of type ‘u_char *’
/home/admin/test/ngx-ip2location-master/ngx_http_ip2location.c:468:5: warning: passing argument 3 of ‘ngx_sock_ntop’ makes pointer from integer without a cast [enabled by default]
In file included from src/core/ngx_core.h:69:0,
                 from src/http/ngx_http.h:13,
                 from /home/admin/test/ngx-ip2location-master/ngx_http_ip2location.c:7:
src/core/ngx_inet.h:110:8: note: expected ‘u_char *’ but argument is of type ‘long unsigned int’
/home/admin/test/ngx-ip2location-master/ngx_http_ip2location.c:468:5: error: too few arguments to function ‘ngx_sock_ntop’
In file included from src/core/ngx_core.h:69:0,
                 from src/http/ngx_http.h:13,
                 from /home/admin/test/ngx-ip2location-master/ngx_http_ip2location.c:7:
src/core/ngx_inet.h:110:8: note: declared here
make[3]: *** [objs/addon/ngx-ip2location-master/ngx_http_ip2location.o] Error 1

nginx 1.6.2

tobsn commented 9 years ago

based on this: https://github.com/yaoweibin/nginx_tcp_proxy_module/commit/dcdfe9eb821a79bc35bf2a5f23d4f80486a0e7a8

I edited the line: size = ngx_sock_ntop(r->connection->sockaddr, address, NGX_INET6_ADDRSTRLEN, 0); to: size = ngx_sock_ntop(r->connection->sockaddr, r->connection->socklen, address, NGX_INET6_ADDRSTRLEN, 0);

it seems to work just fine!

chaizhenhua commented 9 years ago

@tobsn thanks for report this and provide the solution. the file has been updated. thanks a lot.