diff options
| author | Alexander Barton <alex@barton.de> | 2005-01-24 14:17:21 +0000 |
|---|---|---|
| committer | Alexander Barton <alex@barton.de> | 2005-01-24 14:17:21 +0000 |
| commit | 44172a8c7f78f06e9c065724970506e05fbed412 (patch) | |
| tree | e863fba3636e4f09f1628d77612d808a338e39af /src | |
| parent | a6d7fb87392224853e45c8551b6082f1dbbdc7b7 (diff) | |
| download | ngircd-44172a8c7f78f06e9c065724970506e05fbed412.tar.gz ngircd-44172a8c7f78f06e9c065724970506e05fbed412.zip | |
Fixed a possible buffer underrun when reading the MOTD file. Thanks to
Florian Westphal, <westphal@foo.fh-furtwangen.de>.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ngircd/irc-info.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/ngircd/irc-info.c b/src/ngircd/irc-info.c index 26306949..f95d5c5d 100644 --- a/src/ngircd/irc-info.c +++ b/src/ngircd/irc-info.c @@ -14,7 +14,7 @@ #include "portab.h" -static char UNUSED id[] = "$Id: irc-info.c,v 1.22 2004/05/07 11:19:21 alex Exp $"; +static char UNUSED id[] = "$Id: irc-info.c,v 1.23 2005/01/24 14:17:21 alex Exp $"; #include "imp.h" #include <assert.h> @@ -770,6 +770,7 @@ IRC_Show_MOTD( CLIENT *Client ) BOOLEAN ok; CHAR line[127]; FILE *fd; + UINT line_len; assert( Client != NULL ); @@ -790,8 +791,12 @@ IRC_Show_MOTD( CLIENT *Client ) if( ! IRC_WriteStrClient( Client, RPL_MOTDSTART_MSG, Client_ID( Client ), Client_ID( Client_ThisServer( )))) return DISCONNECTED; while( TRUE ) { - if( ! fgets( line, 126, fd )) break; - if( line[strlen( line ) - 1] == '\n' ) line[strlen( line ) - 1] = '\0'; + if( ! fgets( line, sizeof( line ), fd )) break; + + line_len = strlen( line ); + if( line_len > 0 ) pos--; + if( line[line_len] == '\n' ) line[line_len] = '\0'; + if( ! IRC_WriteStrClient( Client, RPL_MOTD_MSG, Client_ID( Client ), line )) { fclose( fd ); |