aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2008-12-14 01:38:59 +0000
committerWilmer van der Gaast <wilmer@gaast.net>2008-12-14 01:38:59 +0000
commite1720ce8958ae014ce38d03b7b9ab129d947921b (patch)
tree94a8989b4d63004246fe2b39db4e8dbe765d756a
parent6d5eb723d73cabcda196189d70bbebc2761eacc3 (diff)
Fixed a bug in the IRC parser where lines that start with a colon and don't
contain any spaces could make BitlBee read uninitialized memory (and possibly even parse it as if it were a command). Also fixed a small memory leak around there.
-rw-r--r--irc.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/irc.c b/irc.c
index 10b4fd83..2dcc625d 100644
--- a/irc.c
+++ b/irc.c
@@ -406,10 +406,8 @@ void irc_process( irc_t *irc )
lines[i] = conv;
}
- if( lines[i] )
+ if( lines[i] && ( cmd = irc_parse_line( lines[i] ) ) )
{
- if( ( cmd = irc_parse_line( lines[i] ) ) == NULL )
- continue;
irc_exec( irc, cmd );
g_free( cmd );
}
@@ -484,7 +482,7 @@ char **irc_parse_line( char *line )
/* Move the line pointer to the start of the command, skipping spaces and the optional prefix. */
if( line[0] == ':' )
{
- for( i = 0; line[i] != ' '; i ++ );
+ for( i = 0; line[i] && line[i] != ' '; i ++ );
line = line + i;
}
for( i = 0; line[i] == ' '; i ++ );