Changes in / [574af7e:79b6213]


Ignore:
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • irc_commands.c

    r574af7e r79b6213  
    321321{
    322322        user_t *u;
    323         char buff[IRC_MAX_LINE];
     323        char buff[IRC_MAX_LINE], *s;
    324324        int lenleft, i;
    325325       
     
    331331        for( i = 1; cmd[i]; i ++ )
    332332        {
    333                 if( ( u = user_find( irc, cmd[i] ) ) && u->online )
    334                 {
    335                         /* [SH] Make sure we don't use too much buffer space. */
    336                         lenleft -= strlen( u->nick ) + 1;
    337                        
    338                         if( lenleft < 0 )
     333                char *this, *next;
     334               
     335                this = cmd[i];
     336                while( *this )
     337                {
     338                        if( ( next = strchr( this, ' ' ) ) )
     339                                *next = 0;
     340                       
     341                        if( ( u = user_find( irc, this ) ) && u->online )
     342                        {
     343                                lenleft -= strlen( u->nick ) + 1;
     344                               
     345                                if( lenleft < 0 )
     346                                        break;
     347                               
     348                                strcat( buff, u->nick );
     349                                strcat( buff, " " );
     350                        }
     351                       
     352                        if( next )
     353                        {
     354                                *next = ' ';
     355                                this = next + 1;
     356                        }
     357                        else
    339358                        {
    340359                                break;
    341                         }
    342                        
    343                         /* [SH] Add the nick to the buffer. Note
    344                          * that an extra space is always added. Even
    345                          * if it's the last nick in the list. Who
    346                          * cares?
    347                          */
    348                        
    349                         strcat( buff, u->nick );
    350                         strcat( buff, " " );
    351                 }
    352         }
    353        
    354         /* [WvG] Well, maybe someone cares, so why not remove it? */
     360                        }   
     361                }
     362               
     363                /* *sigh* */
     364                if( lenleft < 0 )
     365                        break;
     366        }
     367       
    355368        if( strlen( buff ) > 0 )
    356369                buff[strlen(buff)-1] = '\0';
  • protocols/http_client.c

    r574af7e r79b6213  
    157157       
    158158error:
     159        req->status_string = g_strdup( "Error while writing HTTP request" );
     160       
    159161        req->func( req );
    160162       
     
    216218                        if( !sockerr_again() )
    217219                        {
     220                                req->status_string = g_strdup( strerror( errno ) );
    218221                                goto cleanup;
    219222                        }
     
    243246           support... */
    244247        if( req->bytes_read == 0 )
     248        {
     249                req->status_string = g_strdup( "Empty HTTP reply" );
    245250                goto cleanup;
     251        }
    246252       
    247253        /* Zero termination is very convenient. */
     
    264270        else
    265271        {
     272                req->status_string = g_strdup( "Malformed HTTP reply" );
    266273                goto cleanup;
    267274        }
     
    279286        {
    280287                if( sscanf( end1 + 1, "%d", &req->status_code ) != 1 )
     288                {
     289                        req->status_string = g_strdup( "Can't parse status code" );
    281290                        req->status_code = -1;
    282         }
    283         else
    284         {
     291                }
     292                else
     293                {
     294                        char *eol;
     295                       
     296                        if( evil_server )
     297                                eol = strchr( end1, '\n' );
     298                        else
     299                                eol = strchr( end1, '\r' );
     300                       
     301                        req->status_string = g_strndup( end1 + 1, eol - end1 - 1 );
     302                       
     303                        /* Just to be sure... */
     304                        if( ( eol = strchr( req->status_string, '\r' ) ) )
     305                                *eol = 0;
     306                        if( ( eol = strchr( req->status_string, '\n' ) ) )
     307                                *eol = 0;
     308                }
     309        }
     310        else
     311        {
     312                req->status_string = g_strdup( "Can't locate status code" );
    285313                req->status_code = -1;
    286314        }
     
    291319                int error = 0, new_port, new_proto;
    292320               
     321                /* We might fill it again, so let's not leak any memory. */
     322                g_free( req->status_string );
     323                req->status_string = NULL;
     324               
    293325                loc = strstr( req->reply_headers, "\nLocation: " );
    294326                if( loc == NULL ) /* We can't handle this redirect... */
     327                {
     328                        req->status_string = g_strdup( "Can't locate Location: header" );
    295329                        goto cleanup;
     330                }
    296331               
    297332                loc += 11;
     
    310345                           don't need this yet anyway, I won't implement it. */
    311346                       
     347                        req->status_string = g_strdup( "Can't handle recursive redirects" );
     348                       
    312349                        goto cleanup;
    313350                }
     
    327364                        if( !url_set( url, loc ) )
    328365                        {
     366                                req->status_string = g_strdup( "Malformed redirect URL" );
    329367                                g_free( url );
    330368                                goto cleanup;
     
    337375                           going to use strcat(), whether you like it or not. :-) */
    338376                       
    339                         /* First, find the GET/POST/whatever from the original request. */
    340                         s = strchr( req->request, ' ' );
     377                        sprintf( new_request, "GET %s HTTP/1.0", url->file );
     378                       
     379                        s = strstr( req->request, "\r\n" );
    341380                        if( s == NULL )
    342381                        {
     382                                req->status_string = g_strdup( "Error while rebuilding request string" );
    343383                                g_free( new_request );
    344384                                g_free( url );
     
    346386                        }
    347387                       
    348                         *s = 0;
    349                         sprintf( new_request, "%s %s HTTP/1.0\r\n", req->request, url->file );
    350                         *s = ' ';
    351                        
    352                         s = strstr( req->request, "\r\n" );
    353                         if( s == NULL )
    354                         {
    355                                 g_free( new_request );
    356                                 g_free( url );
    357                                 goto cleanup;
    358                         }
    359                        
    360                         strcat( new_request, s + 2 );
     388                        strcat( new_request, s );
    361389                        new_host = g_strdup( url->host );
    362390                        new_port = url->port;
     
    372400               
    373401                req->fd = -1;
    374                 req->ssl = 0;
     402                req->ssl = NULL;
    375403               
    376404                if( new_proto == PROTO_HTTPS )
     
    390418                if( error )
    391419                {
     420                        req->status_string = g_strdup( "Connection problem during redirect" );
    392421                        g_free( new_request );
    393422                        goto cleanup;
     
    418447        g_free( req->request );
    419448        g_free( req->reply_headers );
     449        g_free( req->status_string );
    420450        g_free( req );
    421451}
  • protocols/http_client.h

    r574af7e r79b6213  
    3737        int request_length;
    3838        int status_code;
     39        char *status_string;
    3940        char *reply_headers;
    4041        char *reply_body;
  • protocols/msn/ns.c

    r574af7e r79b6213  
    650650        if( key == NULL )
    651651        {
    652                 hide_login_progress( gc, "Error during Passport authentication" );
     652                char *err;
     653               
     654                err = g_strdup_printf( "Error during Passport authentication (%s)",
     655                                       rep->error_string ? rep->error_string : "Unknown error" );
     656               
     657                hide_login_progress( gc, err );
    653658                signoff( gc );
     659               
     660                g_free( err );
    654661        }
    655662        else
  • protocols/msn/passport.c

    r574af7e r79b6213  
    6969        }
    7070       
    71         reqs = g_malloc( strlen( header ) + strlen( dummy ) + 128 );
    72         sprintf( reqs, "GET %s HTTP/1.0\r\n%s\r\n\r\n", dummy, header );
     71        reqs = g_strdup_printf( "GET %s HTTP/1.0\r\n%s\r\n\r\n", dummy, header );
    7372       
    7473        *dummy = 0;
     
    8887        struct passport_reply *rep = req->data;
    8988       
    90         if( !g_slist_find( msn_connections, rep->data ) || !req->finished || !req->reply_headers )
     89        if( !g_slist_find( msn_connections, rep->data ) )
    9190        {
    9291                destroy_reply( rep );
     
    9493        }
    9594       
    96         if( req->status_code == 200 )
     95        if( req->finished && req->reply_headers && req->status_code == 200 )
    9796        {
    9897                char *dummy;
     
    109108                        rep->result = g_strdup( dummy );
    110109                }
     110                else
     111                {
     112                        rep->error_string = g_strdup( "Could not parse Passport server response" );
     113                }
     114        }
     115        else
     116        {
     117                rep->error_string = g_strdup_printf( "HTTP error: %s",
     118                                      req->status_string ? req->status_string : "Unknown error" );
    111119        }
    112120       
     
    145153}
    146154
    147 #define PPR_REQUEST "GET /rdr/pprdr.asp HTTP/1.0\r\n\r\n"
    148155static int passport_retrieve_dalogin( gpointer func, gpointer data, char *header )
    149156{
     
    155162        rep->header = header;
    156163       
    157         req = http_dorequest( "nexus.passport.com", 443, 1, PPR_REQUEST, passport_retrieve_dalogin_ready, rep );
     164        req = http_dorequest_url( "https://nexus.passport.com/rdr/pprdr.asp", passport_retrieve_dalogin_ready, rep );
    158165       
    159166        if( !req )
     
    169176        char *urlend;
    170177       
    171         if( !g_slist_find( msn_connections, rep->data ) || !req->finished || !req->reply_headers )
     178        if( !g_slist_find( msn_connections, rep->data ) )
    172179        {
    173180                destroy_reply( rep );
     
    175182        }
    176183       
     184        if( !req->finished || !req->reply_headers || req->status_code != 200 )
     185        {
     186                rep->error_string = g_strdup_printf( "HTTP error while fetching DALogin: %s",
     187                                        req->status_string ? req->status_string : "Unknown error" );
     188                goto failure;
     189        }
     190       
    177191        dalogin = strstr( req->reply_headers, "DALogin=" );     
    178192       
    179193        if( !dalogin )
     194        {
     195                rep->error_string = g_strdup( "Parse error while fetching DALogin" );
    180196                goto failure;
     197        }
    181198       
    182199        dalogin += strlen( "DALogin=" );
     
    208225        g_free( rep->result );
    209226        g_free( rep->header );
     227        g_free( rep->error_string );
    210228        g_free( rep );
    211229}
  • protocols/msn/passport.h

    r574af7e r79b6213  
    3939        char *result;
    4040        char *header;
     41        char *error_string;
    4142};
    4243
  • protocols/msn/sb.c

    r574af7e r79b6213  
    523523                {
    524524                        msn_sb_destroy( sb );
    525                         return( 0 );
    526                 }
    527                 if( err->flags & STATUS_FATAL )
     525                        return 0;
     526                }
     527                else if( err->flags & STATUS_FATAL )
    528528                {
    529529                        signoff( gc );
    530                         return( 0 );
    531                 }
    532                 if( err->flags & STATUS_SB_IM_SPARE )
     530                        return 0;
     531                }
     532                else if( err->flags & STATUS_SB_IM_SPARE )
    533533                {
    534534                        if( sb->who )
     
    553553                                sb->msgq = NULL;
    554554                        }
     555                       
     556                        /* Do NOT return 0 here, we want to keep this sb. */
    555557                }
    556558        }
  • protocols/msn/tables.c

    r574af7e r79b6213  
    127127       
    128128        { 910, "Server is busy",                                        STATUS_FATAL },
    129         { 911, "Authentication failed",                                 STATUS_FATAL },
     129        { 911, "Authentication failed",                                 STATUS_SB_FATAL | STATUS_FATAL },
    130130        { 912, "Server is busy",                                        STATUS_FATAL },
    131131        { 913, "Not allowed when hiding",                               0 },
  • protocols/oscar/im.c

    r574af7e r79b6213  
    14691469            case 0x9c:  /* ICQ 5 seems to send this */
    14701470                aim_send_im_ch2_statusmessage(sess, userinfo->sn, args->cookie,
    1471                         gc->away, sess->aim_icq_state, dc);
     1471                        gc->away ? gc->away : "", sess->aim_icq_state, dc);
    14721472                break;
    14731473
Note: See TracChangeset for help on using the changeset viewer.