Changeset 3e1e11af for irc.c


Ignore:
Timestamp:
2007-11-19T23:41:42Z (17 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
d75597b
Parents:
7df5a08
Message:

Fixed NULL pointer dereference (in printf) when connected to a non-socket
(which I do quite often when testing stuff).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • irc.c

    r7df5a08 r3e1e11af  
    7878                        irc->myhost = g_strdup( ipv6_unwrap( buf ) );
    7979                }
    80                 else
    81                 {
    82                         /* Rare, but possible. */
    83                         strncpy( irc->myhost, "localhost.localdomain", NI_MAXHOST );
    84                 }
    8580        }
    8681       
     
    9489                        irc->host = g_strdup( ipv6_unwrap( buf ) );
    9590                }
    96                 else
    97                 {
    98                         /* Rare, but possible. */
    99                         strncpy( irc->host, "localhost.localdomain", NI_MAXHOST );
    100                 }
    101         }
     91        }
     92       
     93        if( irc->host == NULL )
     94                irc->host = g_strdup( "localhost.localdomain" );
     95        if( irc->myhost == NULL )
     96                irc->myhost = g_strdup( "localhost.localdomain" );
    10297       
    10398        if( global.conf->ping_interval > 0 && global.conf->ping_timeout > 0 )
Note: See TracChangeset for help on using the changeset viewer.