diff options
-rw-r--r-- | bitlbee.c | 3 | ||||
-rw-r--r-- | help.c | 5 | ||||
-rw-r--r-- | irc_send.c | 21 | ||||
-rw-r--r-- | motd.txt | 1 | ||||
-rw-r--r-- | protocols/oscar/ssi.c | 2 | ||||
-rw-r--r-- | unix.c | 2 |
6 files changed, 22 insertions, 12 deletions
@@ -135,7 +135,8 @@ int bitlbee_daemon_init() exit( 0 ); setsid(); - chdir( "/" ); + i = chdir( "/" ); + /* Don't use i, just make gcc happy. :-/ */ if( getenv( "_BITLBEE_RESTART_STATE" ) == NULL ) for( i = 0; i < 3; i ++ ) @@ -156,8 +156,9 @@ char *help_get( help_t **help, char *title ) return NULL; } - lseek( h->fd, h->offset.file_offset, SEEK_SET ); - read( h->fd, s, h->length ); + if( lseek( h->fd, h->offset.file_offset, SEEK_SET ) == -1 || + read( h->fd, s, h->length ) != h->length ) + return NULL; } else { @@ -52,24 +52,27 @@ void irc_send_login( irc_t *irc ) void irc_send_motd( irc_t *irc ) { + char motd[2048]; + size_t len; int fd; fd = open( global.conf->motdfile, O_RDONLY ); - if( fd == -1 ) + if( fd == -1 || ( len = read( fd, motd, sizeof( motd ) - 1 ) ) <= 0 ) { irc_send_num( irc, 422, ":We don't need MOTDs." ); } else { - char linebuf[80]; /* Max. line length for MOTD's is 79 chars. It's what most IRC networks seem to do. */ - char *add, max; - int len; + char linebuf[80]; + char *add, max, *in; + in = motd; + motd[len] = '\0'; linebuf[79] = len = 0; max = sizeof( linebuf ) - 1; irc_send_num( irc, 375, ":- %s Message Of The Day - ", irc->root->host ); - while( read( fd, linebuf + len, 1 ) == 1 ) + while( ( linebuf[len] = *(in++) ) ) { if( linebuf[len] == '\n' || len == max ) { @@ -79,13 +82,15 @@ void irc_send_motd( irc_t *irc ) } else if( linebuf[len] == '%' ) { - read( fd, linebuf + len, 1 ); + linebuf[len] = *(in++); if( linebuf[len] == 'h' ) add = irc->root->host; else if( linebuf[len] == 'v' ) add = BITLBEE_VERSION; else if( linebuf[len] == 'n' ) add = irc->user->nick; + else if( linebuf[len] == '\0' ) + in --; else add = "%"; @@ -98,8 +103,10 @@ void irc_send_motd( irc_t *irc ) } } irc_send_num( irc, 376, ":End of MOTD" ); - close( fd ); } + + if( fd != -1 ) + close( fd ); } void irc_usermsg( irc_t *irc, char *format, ... ) @@ -16,3 +16,4 @@ The developers of the Bee hope you have a buzzing time. * BitlBee development team: wilmer, jelmer, Maurits ... Buzzing, haha, get it? +%
\ No newline at end of file diff --git a/protocols/oscar/ssi.c b/protocols/oscar/ssi.c index 76b5b427..f37d98e5 100644 --- a/protocols/oscar/ssi.c +++ b/protocols/oscar/ssi.c @@ -414,7 +414,7 @@ int aim_ssi_cleanlist(aim_session_t *sess, aim_conn_t *conn) for (parentgroup=sess->ssi.items; ((parentgroup) && (parentgroup->type!=AIM_SSI_TYPE_GROUP) && (parentgroup->gid==0x0000)); parentgroup=parentgroup->next); if (!parentgroup) { char *newgroup; - newgroup = (char*)g_malloc(strlen("Unknown")*sizeof(char)); + newgroup = (char*)g_malloc(strlen("Unknown")+1); strcpy(newgroup, "Unknown"); aim_ssi_addgroups(sess, conn, &newgroup, 1); } @@ -166,7 +166,7 @@ int main( int argc, char *argv[] ) /* Looks like env should *not* be freed here as putenv doesn't make a copy. Odd. */ - chdir( old_cwd ); + i = chdir( old_cwd ); close( global.listen_socket ); if( execv( argv[0], argv ) == -1 ) |