Commit Diff
Diff:
4715b17106a3cf4181833670e713be2a307c6a62
248d75e566533e4f1c1278338d1205ad69781177
Commit:
248d75e566533e4f1c1278338d1205ad69781177
Tree:
0d94aaf4f34d5a5fdbd4b0eb592044f00291baff
Author:
Florian Westphal <fw@strlen.de>
Committer:
Florian Westphal <fw@strlen.de>
Date:
Mon Jul 11 20:58:05 2005 UTC
Message:
fix embarassing buffer-off-by one
blob - e9f1223e77ee522da8906784e0b53561c2adcf58
blob + 1f112273397d882f1e4641bfae0aad676cc1a5e8
--- src/ngircd/conn.c
+++ src/ngircd/conn.c
@@ -17,7 +17,7 @@
#include "portab.h"
#include "io.h"
-static char UNUSED id[] = "$Id: conn.c,v 1.161 2005/07/11 14:56:38 fw Exp $";
+static char UNUSED id[] = "$Id: conn.c,v 1.162 2005/07/11 20:58:05 fw Exp $";
#include "imp.h"
#include <assert.h>
@@ -1083,7 +1083,7 @@ Read_Request( CONN_ID Idx )
return;
}
- len = read( My_Connections[Idx].sock, readbuf, sizeof readbuf );
+ len = read( My_Connections[Idx].sock, readbuf, sizeof readbuf -1 );
if( len == 0 ) {
Log( LOG_INFO, "%s:%d (%s) is closing the connection ...",
My_Connections[Idx].host, ntohs( My_Connections[Idx].addr.sin_port),
@@ -1405,8 +1405,7 @@ New_Server( int Server, CONN_ID Idx )
new_addr.sin_port = htons( Conf_Server[Server].port );
new_sock = socket( PF_INET, SOCK_STREAM, 0 );
- if ( new_sock < 0 )
- {
+ if ( new_sock < 0 ) {
/* Can't create socket */
Init_Conn_Struct( Idx );
Conf_Server[Server].conn_id = NONE;
@@ -1417,8 +1416,7 @@ New_Server( int Server, CONN_ID Idx )
if( ! Init_Socket( new_sock )) return;
res = connect( new_sock, (struct sockaddr *)&new_addr, sizeof( new_addr ));
- if(( res != 0 ) && ( errno != EINPROGRESS ))
- {
+ if(( res != 0 ) && ( errno != EINPROGRESS )) {
/* Can't connect socket */
Log( LOG_CRIT, "Can't connect socket: %s!", strerror( errno ));
close( new_sock );
@@ -1429,8 +1427,7 @@ New_Server( int Server, CONN_ID Idx )
/* Client-Struktur initialisieren */
c = Client_NewLocal( Idx, inet_ntoa( new_addr.sin_addr ), CLIENT_UNKNOWNSERVER, false );
- if( ! c )
- {
+ if( ! c ) {
/* Can't create new client structure */
close( new_sock );
Init_Conn_Struct( Idx );
IRCNow