telize

High performance JSON IP and GeoIP REST API (IP Geolocation)
Log | Files | Refs | README | LICENSE

commit d31baab226494da48d83836b82f2cf291f9bca1e
parent 0905e967c421295c2584f49692ecee4e2056928f
Author: Frederic Cambus <fred@statdns.com>
Date:   Fri,  5 Oct 2018 14:13:04 +0200

Use INET6_ADDRSTRLEN for inet_ntop size argument

Diffstat:
Msrc/ip.c | 4++--
Msrc/jsonip.c | 4++--
Msrc/location.c | 4++--
3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/ip.c b/src/ip.c @@ -28,9 +28,9 @@ ip(struct http_request *req) addr = kore_malloc(INET6_ADDRSTRLEN); if (req->owner->addrtype == AF_INET) { - inet_ntop(req->owner->addrtype, &(req->owner->addr.ipv4.sin_addr), addr, sizeof(addr)); + inet_ntop(req->owner->addrtype, &(req->owner->addr.ipv4.sin_addr), addr, INET6_ADDRSTRLEN); } else { - inet_ntop(req->owner->addrtype, &(req->owner->addr.ipv6.sin6_addr), addr, sizeof(addr)); + inet_ntop(req->owner->addrtype, &(req->owner->addr.ipv6.sin6_addr), addr, INET6_ADDRSTRLEN); } if (http_request_header(req, "X-Forwarded-For", &visitor_ip)) { diff --git a/src/jsonip.c b/src/jsonip.c @@ -33,9 +33,9 @@ jsonip(struct http_request *req) addr = kore_malloc(INET6_ADDRSTRLEN); if (req->owner->addrtype == AF_INET) { - inet_ntop(req->owner->addrtype, &(req->owner->addr.ipv4.sin_addr), addr, sizeof(addr)); + inet_ntop(req->owner->addrtype, &(req->owner->addr.ipv4.sin_addr), addr, INET6_ADDRSTRLEN); } else { - inet_ntop(req->owner->addrtype, &(req->owner->addr.ipv6.sin6_addr), addr, sizeof(addr)); + inet_ntop(req->owner->addrtype, &(req->owner->addr.ipv6.sin6_addr), addr, INET6_ADDRSTRLEN); } if (http_request_header(req, "X-Forwarded-For", &visitor_ip)) { diff --git a/src/location.c b/src/location.c @@ -64,9 +64,9 @@ location(struct http_request *req) addr = kore_malloc(INET6_ADDRSTRLEN); if (req->owner->addrtype == AF_INET) { - inet_ntop(req->owner->addrtype, &(req->owner->addr.ipv4.sin_addr), addr, sizeof(addr)); + inet_ntop(req->owner->addrtype, &(req->owner->addr.ipv4.sin_addr), addr, INET6_ADDRSTRLEN); } else { - inet_ntop(req->owner->addrtype, &(req->owner->addr.ipv6.sin6_addr), addr, sizeof(addr)); + inet_ntop(req->owner->addrtype, &(req->owner->addr.ipv6.sin6_addr), addr, INET6_ADDRSTRLEN); } if (http_request_header(req, "X-Forwarded-For", &visitor_ip)) {