Module: ngircd.git
Branch: master
Commit: 765dc320f11f117d63e5285a903dfe8af4a48795
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=765dc320…
Author: Alexander Barton <alex(a)barton.de>
Date: Sun Jan 23 15:14:18 2011 +0100
Read_Request(): don't access possibly free'd CLIENT structure
Handle_Buffer() can shut down connections and remove clients, so after
calling it, we have to make sure that our CLIENT pointer is still valid.
---
src/ngircd/conn.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c
index 98a0543..af79c13 100644
--- a/src/ngircd/conn.c
+++ b/src/ngircd/conn.c
@@ -1455,16 +1455,21 @@ Read_Request( CONN_ID Idx )
/* Update connection statistics */
My_Connections[Idx].bytes_in += len;
+ My_Connections[Idx].bps += Handle_Buffer(Idx);
+
+ /* Make sure that there is still a valid client registered */
+ c = Conn_GetClient(Idx);
+ if (!c)
+ return;
/* Update timestamp of last data received if this connection is
* registered as a user, server or service connection. Don't update
* otherwise, so users have at least Conf_PongTimeout seconds time to
* register with the IRC server -- see Check_Connections().
* Update "lastping", too, if time shifted backwards ... */
- c = Conn_GetClient(Idx);
- if (c && (Client_Type(c) == CLIENT_USER
- || Client_Type(c) == CLIENT_SERVER
- || Client_Type(c) == CLIENT_SERVICE)) {
+ if (Client_Type(c) == CLIENT_USER
+ || Client_Type(c) == CLIENT_SERVER
+ || Client_Type(c) == CLIENT_SERVICE) {
t = time(NULL);
if (My_Connections[Idx].lastdata != t)
My_Connections[Idx].bps = 0;
@@ -1475,7 +1480,6 @@ Read_Request( CONN_ID Idx )
}
/* Look at the data in the (read-) buffer of this connection */
- My_Connections[Idx].bps += Handle_Buffer(Idx);
if (Client_Type(c) != CLIENT_SERVER
&& Client_Type(c) != CLIENT_UNKNOWNSERVER
&& Client_Type(c) != CLIENT_SERVICE
Module: ngircd.git
Branch: master
Commit: 8927700b221ba3cffbde50005319868efbdb1f3e
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=8927700b…
Author: Alexander Barton <alex(a)barton.de>
Date: Tue Jan 18 22:45:01 2011 +0100
Allow "Port = 0" in [Server] blocks
Port number 0 marks remote servers that try to connect to this
daemon, but where this daemon never tries to establis a connection
on its own: only incoming connections are allowed.
---
src/ngircd/conf.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c
index e1fb73b..db91a57 100644
--- a/src/ngircd/conf.c
+++ b/src/ngircd/conf.c
@@ -1361,11 +1361,12 @@ Handle_SERVER( int Line, char *Var, char *Arg )
if( strcasecmp( Var, "Port" ) == 0 ) {
/* Port to which this server should connect */
port = atol( Arg );
- if( port > 0 && port < 0xFFFF )
+ if (port >= 0 && port < 0xFFFF)
New_Server.port = (UINT16)port;
else
- Config_Error( LOG_ERR, "%s, line %d (section \"Server\"): Illegal port number %ld!",
- NGIRCd_ConfFile, Line, port );
+ Config_Error(LOG_ERR,
+ "%s, line %d (section \"Server\"): Illegal port number %ld!",
+ NGIRCd_ConfFile, Line, port );
return;
}
#ifdef SSL_SUPPORT