Changeset 14442b97d8b857fdb5c14368f2e672c3ced511a2

Show
Ignore:
Timestamp:
06/03/07 18:27:18 (2 years ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1173202038 +0000
git-parent:

[0b879fdfa25b12b2d4ca60e119cf4a1bdafe5c8b]

git-author:
Rémi Denis-Courmont <rem@videolan.org> 1173202038 +0000
Message:

Use vlc_b64_decode instead of local implementation

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/network/httpd.c

    rcf8e72e r14442b9  
    3636#include <vlc_tls.h> 
    3737#include <vlc_acl.h> 
     38#include <vlc_strings.h> 
    3839#include "../libvlc.h" 
    3940 
     
    187188 * Various functions 
    188189 *****************************************************************************/ 
    189 /*char b64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";*/ 
    190 static void b64_decode( char *restrict dest, const char *restrict src ) 
    191 { 
    192     int  i_level; 
    193     int  last = 0; 
    194     int  b64[256] = { 
    195         -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,  /* 00-0F */ 
    196         -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,  /* 10-1F */ 
    197         -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,  /* 20-2F */ 
    198         52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1,  /* 30-3F */ 
    199         -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,  /* 40-4F */ 
    200         15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,  /* 50-5F */ 
    201         -1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,  /* 60-6F */ 
    202         41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1,  /* 70-7F */ 
    203         -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,  /* 80-8F */ 
    204         -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,  /* 90-9F */ 
    205         -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,  /* A0-AF */ 
    206         -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,  /* B0-BF */ 
    207         -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,  /* C0-CF */ 
    208         -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,  /* D0-DF */ 
    209         -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,  /* E0-EF */ 
    210         -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1   /* F0-FF */ 
    211         }; 
    212  
    213     for( i_level = 0; *src != '\0'; src++ ) 
    214     { 
    215         int  c; 
    216  
    217         c = b64[(unsigned int)*src]; 
    218         if( c == -1 ) 
    219         { 
    220             continue; 
    221         } 
    222  
    223         switch( i_level ) 
    224         { 
    225             case 0: 
    226                 i_level++; 
    227                 break; 
    228             case 1: 
    229                 *dest++ = ( last << 2 ) | ( ( c >> 4)&0x03 ); 
    230                 i_level++; 
    231                 break; 
    232             case 2: 
    233                 *dest++ = ( ( last << 4 )&0xf0 ) | ( ( c >> 2 )&0x0f ); 
    234                 i_level++; 
    235                 break; 
    236             case 3: 
    237                 *dest++ = ( ( last &0x03 ) << 6 ) | c; 
    238                 i_level = 0; 
    239         } 
    240         last = c; 
    241     } 
    242  
    243     *dest = '\0'; 
    244 } 
    245  
    246190static struct 
    247191{ 
     
    22052149                                    /* create the headers */ 
    22062150                                    const char *b64 = httpd_MsgGet( query, "Authorization" ); /* BASIC id */ 
    2207                                     char *auth
     2151                                    char *auth = NULL
    22082152                                    char *id; 
    22092153 
     
    22172161                                            b64++; 
    22182162                                        } 
    2219                                         auth = malloc( strlen(b64) + 1 ); 
    2220                                         b64_decode( auth, b64 ); 
     2163                                        auth = vlc_b64_decode( b64 ); 
    22212164                                    } 
    2222                                     else 
    2223                                     { 
    2224                                         auth = strdup( "" ); 
    2225                                     } 
    2226  
    2227                                     if( strcmp( id, auth ) ) 
     2165 
     2166                                    if( (auth == NULL) || strcmp( id, auth ) ) 
    22282167                                    { 
    22292168                                        httpd_MsgAdd( answer, "WWW-Authenticate", "Basic realm=\"%s\"", url->psz_user );