Changeset 3e1e11af


Ignore:
Timestamp:
2007-11-19T23:41:42Z (16 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).

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • bitlbee.c

    r7df5a08 r3e1e11af  
    5050        hints.ai_flags = AI_ADDRCONFIG | AI_PASSIVE;
    5151
    52         i = getaddrinfo( global.conf->iface, global.conf->port, &hints,
    53                                                 &addrinfo_bind );
     52        i = getaddrinfo( global.conf->iface, global.conf->port, &hints, &addrinfo_bind );
    5453        if( i )
    5554        {
    56                 log_message( LOGLVL_ERROR, "Couldn't parse address `%s': %s", 
    57                                         global.conf->iface, gai_strerror(i) );
     55                log_message( LOGLVL_ERROR, "Couldn't parse address `%s': %s",
     56                                          global.conf->iface, gai_strerror(i) );
    5857                return -1;
    5958        }
     
    6362        for( res = addrinfo_bind; res; res = res->ai_next )
    6463        {
    65                 global.listen_socket = socket( res->ai_family, res->ai_socktype,
    66                                                                            res->ai_protocol );
     64                global.listen_socket = socket( res->ai_family, res->ai_socktype, res->ai_protocol );
    6765                if( global.listen_socket < 0 )
    6866                        continue;
     
    7068                /* TIME_WAIT (?) sucks.. */
    7169                i = 1;
    72                 setsockopt( global.listen_socket, SOL_SOCKET, SO_REUSEADDR, &i,
    73                                         sizeof( i ) );
     70                setsockopt( global.listen_socket, SOL_SOCKET, SO_REUSEADDR, &i, sizeof( i ) );
    7471
    7572                i = bind( global.listen_socket, res->ai_addr, res->ai_addrlen );
     
    119116                ipc_master_load_state();
    120117
    121         if( global.conf->runmode == RUNMODE_DAEMON ||
    122                 global.conf->runmode == RUNMODE_FORKDAEMON )
     118        if( global.conf->runmode == RUNMODE_DAEMON || global.conf->runmode == RUNMODE_FORKDAEMON )
    123119                ipc_master_listen_socket();
    124120       
  • 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.