Changeset 1875

Show
Ignore:
Timestamp:
06/15/2007 04:22:30 PM (15 months ago)
Author:
jan
Message:

* fixed mem-leak in mod_auth (reported by Stefan Esser)
* fixed crash with md5-sess and cnonce not set in mod_auth (reported

by Stefan Esser)

* fixed missing check for base64 encoded string in mod_auth and Basic

auth (reported by Stefan Esser)

* fixed possible crash in Auth-Digest header parser on trailing WS in

mod_auth (reported by Stefan Esser)

Location:
branches/lighttpd-1.4.x
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/lighttpd-1.4.x/NEWS

    r1874 r1875  
    1414  * fixed crash on duplicate headers with trailing WS (#1232) 
    1515  * fixed accepting more connections then requested (#1216) 
     16  * fixed mem-leak in mod_auth (reported by Stefan Esser) 
     17  * fixed crash with md5-sess and cnonce not set in mod_auth (reported by Stefan Esser) 
     18  * fixed missing check for base64 encoded string in mod_auth and Basic auth 
     19    (reported by Stefan Esser) 
     20  * fixed possible crash in Auth-Digest header parser on trailing WS in  
     21    mod_auth (reported by Stefan Esser)  
    1622 
    1723- 1.4.15 - 2007-04-13 
  • branches/lighttpd-1.4.x/src/http_auth.c

    r1721 r1875  
    831831        username = buffer_init(); 
    832832 
    833         base64_decode(username, realm_str); 
     833        if (!base64_decode(username, realm_str)) { 
     834                buffer_free(username); 
     835 
     836                log_error_write(srv, __FILE__, __LINE__, "sb", "decodeing base64-string failed", username); 
     837 
     838                return 0; 
     839        } 
    834840 
    835841        /* r2 == user:password */ 
     
    968974                /* skip whitespaces */ 
    969975                while (*c == ' ' || *c == '\t') c++; 
    970                 if (!c) break; 
     976                if (!*c) break; 
    971977 
    972978                for (i = 0; dkv[i].key; i++) { 
     
    10171023                log_error_write(srv, __FILE__, __LINE__, "s", 
    10181024                                "digest: missing field"); 
     1025 
     1026                buffer_free(b); 
     1027                return -1; 
     1028        } 
     1029 
     1030        /** 
     1031         * protect the md5-sess against missing cnonce and nonce 
     1032         */ 
     1033        if (algorithm && 
     1034            0 == strcasecmp(algorithm, "md5-sess") && 
     1035            (!nonce || !cnonce)) { 
     1036                log_error_write(srv, __FILE__, __LINE__, "s", 
     1037                                "digest: (md5-sess: missing field"); 
     1038 
     1039                buffer_free(b); 
    10191040                return -1; 
    10201041        } 
  • branches/lighttpd-1.4.x/tests/mod-auth.t

    r1374 r1875  
    99use strict; 
    1010use IO::Socket; 
    11 use Test::More tests => 10; 
     11use Test::More tests => 13; 
    1212use LightyTest; 
    1313 
     
    9494ok($tf->handle_http($t) == 0, 'Digest-Auth: missing nc (noncecount instead), no crash'); 
    9595 
     96$t->{REQUEST}  = ( <<EOF 
     97GET /server-status HTTP/1.0 
     98Authorization: Basic = 
     99EOF 
     100 ); 
     101$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 401 } ]; 
     102ok($tf->handle_http($t) == 0, 'Basic-Auth: Invalid Base64'); 
     103 
     104 
     105$t->{REQUEST}  = ( <<EOF 
     106GET /server-status HTTP/1.0 
     107User-Agent: Wget/1.9.1 
     108Authorization: Digest username="jan", realm="jan", 
     109        nonce="b1d12348b4620437c43dd61c50ae4639", algorithm="md5-sess", 
     110        uri="/MJ-BONG.xm.mpc", qop=auth, noncecount=00000001", 
     111        cnonce="036FCA5B86F7E7C4965C7F9B8FE714B7", 
     112        nc="asd", 
     113        response="29B32C2953C763C6D033C8A49983B87E" 
     114EOF 
     115 ); 
     116$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 401 } ]; 
     117ok($tf->handle_http($t) == 0, 'Digest-Auth: md5-sess + missing cnonce'); 
     118 
     119$t->{REQUEST}  = ( <<EOF 
     120GET /server-status HTTP/1.0 
     121User-Agent: Wget/1.9.1 
     122Authorization: Digest username="jan", realm="jan", 
     123        nonce="b1d12348b4620437c43dd61c50ae4639", algorithm="md5-sess", 
     124        uri="/MJ-BONG.xm.mpc", qop=auth, noncecount=00000001", 
     125        cnonce="036FCA5B86F7E7C4965C7F9B8FE714B7", 
     126        nc="asd", 
     127        response="29B32C2953C763C6D033C8A49983B87E"      
     128EOF 
     129 ); 
     130$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 401 } ]; 
     131ok($tf->handle_http($t) == 0, 'Digest-Auth: trailing WS'); 
     132 
    96133 
    97134