diff options
author | celest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2005-02-26 08:38:22 +0000 |
---|---|---|
committer | celest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2005-02-26 08:38:22 +0000 |
commit | 8d96e1c00a9d7dd4562ec525e40384be0bf726e1 (patch) | |
tree | 25fb03614d065afd2ace4ed3b1a7b6ba27ae8ac3 /src/common/socket.c | |
parent | ccd3e0e2d45eac452406eab7dfcfa7a08a369042 (diff) | |
download | hercules-8d96e1c00a9d7dd4562ec525e40384be0bf726e1.tar.gz hercules-8d96e1c00a9d7dd4562ec525e40384be0bf726e1.tar.bz2 hercules-8d96e1c00a9d7dd4562ec525e40384be0bf726e1.tar.xz hercules-8d96e1c00a9d7dd4562ec525e40384be0bf726e1.zip |
* Added jA's dummy socket to prevent fd crashes
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1183 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common/socket.c')
-rw-r--r-- | src/common/socket.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/common/socket.c b/src/common/socket.c index 02ba49cb9..ad4e7d2e2 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -54,6 +54,9 @@ struct socket_data *session[FD_SETSIZE]; static int null_parse(int fd); static int (*default_func_parse)(int) = null_parse; +// fdが不正な時に代わりに読み書きするバッファ +unsigned char socket_dummy[SOCKET_DUMMY_SIZE]; + static int null_console_parse(char *buf); static int (*default_console_parse)(char*) = null_console_parse; @@ -431,7 +434,10 @@ int delete_session(int fd) int realloc_fifo(int fd,int rfifo_size,int wfifo_size) { - struct socket_data *s=session[fd]; + struct socket_data *s; + + if (fd <= 0) return 0; + s = session[fd]; if( s->max_rdata != rfifo_size && s->rdata_size < rfifo_size){ RECREATE(s->rdata, unsigned char, rfifo_size); s->max_rdata = rfifo_size; @@ -445,7 +451,10 @@ int realloc_fifo(int fd,int rfifo_size,int wfifo_size) int WFIFOSET(int fd,int len) { - struct socket_data *s=session[fd]; + struct socket_data *s; + + if (fd <= 0) return 0; + s = session[fd]; if (s == NULL || s->wdata == NULL) return 0; if( s->wdata_size+len+16384 > s->max_wdata ){ @@ -531,7 +540,10 @@ void do_socket(void) int RFIFOSKIP(int fd,int len) { - struct socket_data *s=session[fd]; + struct socket_data *s; + + if (fd <= 0) return 0; + s = session[fd]; if (s->rdata_size-s->rdata_pos-len<0) { fprintf(stderr,"too many skip\n"); |