* shuffled members of wcsession -> do a make clean or everything will burst in your...
[citadel.git] / webcit / locate_host.c
index 7b5869907c8cb3cdb9c54e13295b3a5689c43ff4..8b03833d5e3a97afe148b7ada2faaead331b0e6f 100644 (file)
@@ -15,7 +15,7 @@
  * \param tbuf the returnbuffer
  * \param client_socket the sock fd where the client is connected
  */
-void locate_host(char *tbuf, int client_socket)
+void locate_host(StrBuf *tbuf, int client_socket)
 {
        struct sockaddr_in cs;
        struct hostent *ch;
@@ -25,7 +25,7 @@ void locate_host(char *tbuf, int client_socket)
 
        len = sizeof(cs);
        if (getpeername(client_socket, (struct sockaddr *) &cs, &len) < 0) {
-               strcpy(tbuf, "<unknown>");
+               StrBufAppendBufPlain(tbuf, HKEY("<unknown>"), 0);
                return;
        }
        if ((ch = gethostbyaddr((char *) &cs.sin_addr, sizeof(cs.sin_addr),
@@ -35,10 +35,10 @@ void locate_host(char *tbuf, int client_socket)
                a2 = ((*i++) & 0xff);
                a3 = ((*i++) & 0xff);
                a4 = ((*i++) & 0xff);
-               sprintf(tbuf, "%d.%d.%d.%d", a1, a2, a3, a4);
+               StrBufPrintf(tbuf, "%d.%d.%d.%d", a1, a2, a3, a4);
                return;
        }
-       safestrncpy(tbuf, ch->h_name, 64);
+       StrBufAppendBufPlain(tbuf, ch->h_name, -1, 0);
 }
 
 /*@}*/