aboutsummaryrefslogtreecommitdiffstats
path: root/irc.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2007-11-19 23:41:42 +0000
committerWilmer van der Gaast <wilmer@gaast.net>2007-11-19 23:41:42 +0000
commit3e1e11afc869238d5cfca899d4814fea8a877687 (patch)
tree968a997adcf2bfae99655e71b756397e02128f8d /irc.c
parent7df5a087131d3b1bbe7add0907cd72217692ffd0 (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.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/irc.c b/irc.c
index ebb2876b..5531addb 100644
--- a/irc.c
+++ b/irc.c
@@ -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 );