Changeset 94


Ignore:
Timestamp:
Mar 7, 2008, 8:32:14 PM (10 years ago)
Author:
Sam Hocevar
Message:
  • Prevent a crash if create_listen_socket() fails.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/net/tcpip.cpp

    r56 r94  
    428428        end_notify();
    429429
    430   if (!responder) {
     430    if (!responder)
     431    {
    431432//#ifdef TCPIP_DEBUG
    432                 fprintf(stderr,"Creating responder on port %d\n",port);
     433        fprintf(stderr,"Creating responder on port %d\n",port);
    433434//#endif
    434     responder = create_listen_socket(port, net_socket::SOCKET_FAST);
    435                 responder->read_selectable();
    436                 responder->write_unselectable();
    437     bcast = (ip_address *)get_local_address();
    438     bcast->set_port(port);
     435        responder = create_listen_socket(port, net_socket::SOCKET_FAST);
     436        if(responder)
     437        {
     438            responder->read_selectable();
     439            responder->write_unselectable();
     440            bcast = (ip_address *)get_local_address();
     441            bcast->set_port(port);
    439442   
    440443//#ifdef TCPIP_DEBUG
    441                 *((unsigned char *)(&bcast->addr.sin_addr)+3) = 255;
    442                 bcast->store_string(s,256);
    443                 fprintf(stderr,"Simulating broadcast to [%s]\n",s);
     444            *((unsigned char *)(&bcast->addr.sin_addr)+3) = 255;
     445            bcast->store_string(s,256);
     446            fprintf(stderr,"Simulating broadcast to [%s]\n",s);
    444447//#endif
    445448
    446                 *((unsigned char *)(&bcast->addr.sin_addr)+3) = 0;             
    447         }
     449            *((unsigned char *)(&bcast->addr.sin_addr)+3) = 0;         
     450        }
     451    }
    448452
    449453  if (responder)
Note: See TracChangeset for help on using the changeset viewer.