Changeset c758dd299ee12494f2b28e51109e70ba67099f92

Show
Ignore:
Timestamp:
10/09/07 08:48:49 (1 year ago)
Author:
Rafaël Carré <funman@videolan.org>
git-committer:
Rafaël Carré <funman@videolan.org> 1191912529 +0000
git-parent:

[8acbb8ac692b609fe4c43bf06044cf2cea49dadc]

git-author:
Rafaël Carré <funman@videolan.org> 1191912529 +0000
Message:

bonjour: checks asprintf() return value, checks name before using it

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/services_discovery/bonjour.c

    re40d134 rc758dd2  
    142142        avahi_address_snprint(a, (sizeof(a)/sizeof(a[0]))-1, address); 
    143143        if( protocol == AVAHI_PROTO_INET6 ) 
    144             asprintf( &psz_addr, "[%s]", a ); 
     144            if( asprintf( &psz_addr, "[%s]", a ) == -1 ) 
     145                return; 
    145146 
    146147        if( txt != NULL ) 
     
    154155                value != NULL ) 
    155156            { 
    156                 asprintf( &psz_uri, "http://%s:%d%s", 
    157                           psz_addr != NULL ? psz_addr : a, port, value ); 
     157                if( asprintf( &psz_uri, "http://%s:%d%s", 
     158                          psz_addr != NULL ? psz_addr : a, port, value ) == -1 ) 
     159                { 
     160                    free( psz_addr ); 
     161                    return; 
     162                } 
    158163            } 
    159164            if( key != NULL ) 
     
    164169        else 
    165170        { 
    166             asprintf( &psz_uri, "http://%s:%d", 
    167                       psz_addr != NULL ? psz_addr : a, port ); 
     171            if( asprintf( &psz_uri, "http://%s:%d", 
     172                      psz_addr != NULL ? psz_addr : a, port ) == -1 ) 
     173            { 
     174                free( psz_addr ); 
     175                return; 
     176            } 
    168177        } 
    169178 
     
    205214    services_discovery_t *p_sd = ( services_discovery_t* )userdata; 
    206215    services_discovery_sys_t *p_sys = p_sd->p_sys; 
    207  
    208216    if( event == AVAHI_BROWSER_NEW ) 
    209217    { 
     
    219227        } 
    220228    } 
    221     else 
     229    else if( name ) 
    222230    { 
    223231        /** \todo Store the input id and search it, rather than searching the items */