From f92def7eefc3f2791be389b7d0a0392ef7f90c1f Mon Sep 17 00:00:00 2001 From: Andy Green Date: Wed, 9 Mar 2011 15:02:20 +0000 Subject: [PATCH] use unsigned peer dotted quad Reported-by: Pierre-Paul Lavoie Signed-off-by: Andy Green --- lib/libwebsockets.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index 9bb44b48..40d25a8b 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -369,7 +369,7 @@ libwebsockets_get_peer_addresses(int fd, char *name, int name_len, struct hostent *host; struct hostent *host1; char ip[128]; - char *p; + unsigned char *p; int n; rip[0] = '\0'; @@ -394,16 +394,16 @@ libwebsockets_get_peer_addresses(int fd, char *name, int name_len, host1 = gethostbyname(host->h_name); if (host1 == NULL) return; - p = (char *)host1; + p = (unsigned char *)host1; n = 0; while (p != NULL) { - p = host1->h_addr_list[n++]; + p = (unsigned char *)host1->h_addr_list[n++]; if (p == NULL) continue; if (host1->h_addrtype != AF_INET) continue; - sprintf(ip, "%d.%d.%d.%d", + sprintf(ip, "%u.%u.%u.%u", p[0], p[1], p[2], p[3]); p = NULL; strncpy(rip, ip, rip_len);