Changeset 9ad86bb


Ignore:
Timestamp:
2008-03-15T16:09:50Z (16 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
a869d91
Parents:
7f421d6
Message:

Fixed issues with "long" URLs in url.c. Reusing code from 2001 wasn't a
good idea...

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • bitlbee.h

    r7f421d6 r9ad86bb  
    3333#define VERSION BITLBEE_VERSION
    3434
    35 #define MAX_STRING 128
     35#define MAX_STRING 511
    3636
    3737#if HAVE_CONFIG_H
  • lib/url.c

    r7f421d6 r9ad86bb  
    2626#include "url.h"
    2727
    28 /* Convert an URL to a url_t structure                                  */
     28/* Convert an URL to a url_t structure */
    2929int url_set( url_t *url, char *set_url )
    3030{
    31         char s[MAX_STRING];
     31        char s[MAX_STRING+1];
    3232        char *i;
    3333       
    34         /* protocol://                                                  */
     34        memset( url, 0, sizeof( url_t ) );
     35        memset( s, 0, sizeof( s ) );
     36       
     37        /* protocol:// */
    3538        if( ( i = strstr( set_url, "://" ) ) == NULL )
    3639        {
     
    4952                        url->proto = PROTO_SOCKS5;
    5053                else
    51                 {
    52                         return( 0 );
    53                 }
     54                        return 0;
     55               
    5456                strncpy( s, i + 3, MAX_STRING );
    5557        }
    5658       
    57         /* Split                                                        */
     59        /* Split */
    5860        if( ( i = strchr( s, '/' ) ) == NULL )
    5961        {
     
    6769        strncpy( url->host, s, MAX_STRING );
    6870       
    69         /* Check for username in host field                             */
     71        /* Check for username in host field */
    7072        if( strrchr( url->host, '@' ) != NULL )
    7173        {
     
    7678                *url->pass = 0;
    7779        }
    78         /* If not: Fill in defaults                                     */
     80        /* If not: Fill in defaults */
    7981        else
    8082        {
     
    8284        }
    8385       
    84         /* Password?                                                    */
     86        /* Password? */
    8587        if( ( i = strchr( url->user, ':' ) ) != NULL )
    8688        {
     
    8890                strcpy( url->pass, i + 1 );
    8991        }
    90         /* Port number?                                                 */
     92        /* Port number? */
    9193        if( ( i = strchr( url->host, ':' ) ) != NULL )
    9294        {
  • lib/url.h

    r7f421d6 r9ad86bb  
    2626#include "bitlbee.h"
    2727
    28 #define PROTO_HTTP              2
    29 #define PROTO_HTTPS             5
    30 #define PROTO_SOCKS4    3
    31 #define PROTO_SOCKS5    4
    32 #define PROTO_DEFAULT   PROTO_HTTP
     28#define PROTO_HTTP      2
     29#define PROTO_HTTPS     5
     30#define PROTO_SOCKS4    3
     31#define PROTO_SOCKS5    4
     32#define PROTO_DEFAULT   PROTO_HTTP
    3333
    3434typedef struct url
     
    3636        int proto;
    3737        int port;
    38         char host[MAX_STRING];
    39         char file[MAX_STRING];
    40         char user[MAX_STRING];
    41         char pass[MAX_STRING];
     38        char host[MAX_STRING+1];
     39        char file[MAX_STRING+1];
     40        char user[MAX_STRING+1];
     41        char pass[MAX_STRING+1];
    4242} url_t;
    4343
Note: See TracChangeset for help on using the changeset viewer.