summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-04-29 14:34:02 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-04-29 14:34:02 +0000
commit9a530c03732051934d0f0cc96be7658e90e9d5c2 (patch)
tree69c74580bea36ec6519d7345f4971fced9b19ec0 /src/common
parent29856008bba6adc02a38c44ef1f03aef1743b313 (diff)
downloadhercules-9a530c03732051934d0f0cc96be7658e90e9d5c2.tar.gz
hercules-9a530c03732051934d0f0cc96be7658e90e9d5c2.tar.bz2
hercules-9a530c03732051934d0f0cc96be7658e90e9d5c2.tar.xz
hercules-9a530c03732051934d0f0cc96be7658e90e9d5c2.zip
* Ladmin fixes
- Added vs8 project file for ladmin - Replaced all occurences of printf in ladmin.c with ShowMessage - Fixed ladmin working with ips using the wrong byte orer * Fixed @jumpto displaying the incorrect player name * Added more safeguards to socket.c against socket ids out of range git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10409 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common')
-rw-r--r--src/common/socket.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/common/socket.c b/src/common/socket.c
index f406a0eea..73b0fb06b 100644
--- a/src/common/socket.c
+++ b/src/common/socket.c
@@ -249,12 +249,12 @@ int connect_client(int listen_fd)
return -1;
}
- if ( fd >= FD_SETSIZE )
- { //More connections than we can handle!
- ShowError("accept failed. Received socket #%d is greater than can we handle! Increase the value of FD_SETSIZE (currently %d) for your OS to fix this!\n", fd, FD_SETSIZE);
+ if ( fd >= FD_SETSIZE ) { //Not enough capacity for this socket
+ ShowError("connect_client: New socket #%d is greater than can we handle! Increase the value of FD_SETSIZE (currently %d) for your OS to fix this!\n", fd, FD_SETSIZE);
closesocket(fd);
return -1;
}
+
setsocketopts(fd);
set_nonblocking(fd, 1);
@@ -265,11 +265,9 @@ int connect_client(int listen_fd)
}
#endif
+ if( fd_max <= fd ) fd_max = fd + 1;
FD_SET(fd,&readfds);
- if( fd_max <= fd )
- fd_max = fd + 1;
-
create_session(fd, recv_to_fifo, send_from_fifo, default_func_parse);
session[fd]->client_addr = ntohl(client_address.sin_addr.s_addr);
session[fd]->rdata_tick = last_tick;
@@ -290,6 +288,12 @@ int make_listen_bind(uint32 ip, uint16 port)
exit(1);
}
+ if ( fd >= FD_SETSIZE ) { //Not enough capacity for this socket
+ ShowError("make_listen_bind: New socket #%d is greater than can we handle! Increase the value of FD_SETSIZE (currently %d) for your OS to fix this!\n", fd, FD_SETSIZE);
+ closesocket(fd);
+ return -1;
+ }
+
setsocketopts(fd);
set_nonblocking(fd, 1);
@@ -314,7 +318,7 @@ int make_listen_bind(uint32 ip, uint16 port)
}
if(fd_max <= fd) fd_max = fd + 1;
- FD_SET(fd, &readfds );
+ FD_SET(fd, &readfds);
create_session(fd, connect_client, null_send, null_parse);
@@ -334,6 +338,12 @@ int make_connection(uint32 ip, uint16 port)
return -1;
}
+ if ( fd >= FD_SETSIZE ) { //Not enough capacity for this socket
+ ShowError("make_connection: New socket #%d is greater than can we handle! Increase the value of FD_SETSIZE (currently %d) for your OS to fix this!\n", fd, FD_SETSIZE);
+ closesocket(fd);
+ return -1;
+ }
+
setsocketopts(fd);
server_address.sin_family = AF_INET;
@@ -351,8 +361,7 @@ int make_connection(uint32 ip, uint16 port)
//Now the socket can be made non-blocking. [Skotlex]
set_nonblocking(fd, 1);
- if (fd_max <= fd)
- fd_max = fd + 1;
+ if (fd_max <= fd) fd_max = fd + 1;
FD_SET(fd,&readfds);
create_session(fd, recv_to_fifo, send_from_fifo, default_func_parse);