diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2007-11-19 23:41:42 +0000 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2007-11-19 23:41:42 +0000 |
commit | 3e1e11afc869238d5cfca899d4814fea8a877687 (patch) | |
tree | 968a997adcf2bfae99655e71b756397e02128f8d /irc.c | |
parent | 7df5a087131d3b1bbe7add0907cd72217692ffd0 (diff) |
Fixed NULL pointer dereference (in printf) when connected to a non-socket
(which I do quite often when testing stuff).
Diffstat (limited to 'irc.c')
-rw-r--r-- | irc.c | 15 |
1 files changed, 5 insertions, 10 deletions
@@ -77,11 +77,6 @@ irc_t *irc_new( int fd ) { irc->myhost = g_strdup( ipv6_unwrap( buf ) ); } - else - { - /* Rare, but possible. */ - strncpy( irc->myhost, "localhost.localdomain", NI_MAXHOST ); - } } if( getpeername( irc->fd, (struct sockaddr*) &sock, &socklen ) == 0 ) @@ -93,13 +88,13 @@ irc_t *irc_new( int fd ) { irc->host = g_strdup( ipv6_unwrap( buf ) ); } - else - { - /* Rare, but possible. */ - strncpy( irc->host, "localhost.localdomain", NI_MAXHOST ); - } } + if( irc->host == NULL ) + irc->host = g_strdup( "localhost.localdomain" ); + if( irc->myhost == NULL ) + irc->myhost = g_strdup( "localhost.localdomain" ); + if( global.conf->ping_interval > 0 && global.conf->ping_timeout > 0 ) irc->ping_source_id = b_timeout_add( global.conf->ping_interval * 1000, irc_userping, irc ); |