From ff3f693c894d2a7f689d3f85f5aa0efa47135df4 Mon Sep 17 00:00:00 2001 From: brain Date: Tue, 13 Dec 2005 21:38:13 +0000 Subject: Eliminated a strlcpy git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2382 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/inspircd.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/inspircd.cpp b/src/inspircd.cpp index a2b0dea75..6d664389d 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -2330,7 +2330,7 @@ int InspIRCd(char** argv, int argc) userrec* cu = NULL; InspSocket* s = NULL; InspSocket* s_del = NULL; - char target[MAXBUF]; + char* target; unsigned int numberactive; sockaddr_in sock_us; // our port number socklen_t uslen; // length of our port number @@ -2487,14 +2487,13 @@ int InspIRCd(char** argv, int argc) /* It's a listener */ uslen = sizeof(sock_us); - themlen = sizeof(sock_them); - length = sizeof (client); - incomingSockfd = accept (activefds[activefd], (struct sockaddr *) &client, &length); + length = sizeof(client); + incomingSockfd = accept (activefds[activefd],(struct sockaddr*)&client,&length); if (!getsockname(incomingSockfd,(sockaddr*)&sock_us,&uslen)) { in_port = ntohs(sock_us.sin_port); log(DEBUG,"Accepted socket %d",incomingSockfd); - strlcpy (target, (char *) inet_ntoa (client.sin_addr), MAXBUF); + target = (char*)inet_ntoa(client.sin_addr); /* Years and years ago, we used to resolve here * using gethostbyaddr(). That is sucky and we * don't do that any more... @@ -2503,7 +2502,7 @@ int InspIRCd(char** argv, int argc) { FOREACH_MOD OnRawSocketAccept(incomingSockfd, target, in_port); statsAccept++; - AddClient(incomingSockfd, target, in_port, false, inet_ntoa (client.sin_addr)); + AddClient(incomingSockfd, target, in_port, false, target); log(DEBUG,"Adding client on port %lu fd=%lu",(unsigned long)in_port,(unsigned long)incomingSockfd); } else @@ -2515,7 +2514,9 @@ int InspIRCd(char** argv, int argc) } else { - log(DEBUG,"Couldnt look up the port number for fd %lu(?!)",incomingSockfd); + log(DEBUG,"Couldnt look up the port number for fd %lu (OS BROKEN?!)",incomingSockfd); + shutdown(incomingSockfd,2); + close(incomingSockfd); } break; -- cgit v1.2.3