~ubuntu-branches/ubuntu/jaunty/squid3/jaunty

« back to all changes in this revision

Viewing changes to src/auth/basic/auth_basic.cc

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2008-06-01 05:48:22 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080601054822-okaglok79te8qmln
Tags: 3.0.STABLE6-2
* debian/control
  - Fixed suggestion on squidlcient package

Show diffs side-by-side

added added

removed removed

Lines of Context:
322
322
 
323
323
AuthBasicConfig::~AuthBasicConfig()
324
324
{
325
 
    if(basicAuthRealm)
326
 
        delete basicAuthRealm;
327
 
    basicAuthRealm = NULL;
 
325
    safe_free(basicAuthRealm);
328
326
}
329
327
 
330
328
void
393
391
bool
394
392
BasicUser::decodeCleartext()
395
393
{
396
 
    char *sent_auth;
 
394
    char *sent_auth = NULL;
 
395
 
397
396
    /* username and password */
398
397
    sent_auth = xstrdup(httpAuthHeader);
 
398
 
399
399
    /* Trim trailing \n before decoding */
400
400
    strtok(sent_auth, "\n");
401
401
 
402
402
    cleartext = uudecode(sent_auth);
403
403
 
404
 
    xfree(sent_auth);
 
404
    safe_free(sent_auth);
 
405
 
 
406
    if (!cleartext)
 
407
        return false;
405
408
 
406
409
    /*
407
410
     * Don't allow NL or CR in the credentials.
420
423
void
421
424
BasicUser::extractUsername()
422
425
{
423
 
    char * tempusername = cleartext;
424
 
    /* terminate the username string */
425
 
 
426
 
    if ((cleartext = strchr(tempusername, ':')) != NULL)
427
 
        *(cleartext)++ = '\0';
428
 
 
429
 
    username (tempusername);
 
426
    char * seperator = strchr(cleartext, ':');
 
427
 
 
428
    if (seperator == NULL) {
 
429
        username(cleartext);
 
430
    } else {
 
431
        /* terminate the username */
 
432
        *seperator = '\0';
 
433
 
 
434
        username(cleartext);
 
435
 
 
436
        /* replace the colon so we can find the password */
 
437
        *seperator = ':';
 
438
    }
430
439
 
431
440
    if (!basicConfig.casesensitive)
432
441
        Tolower((char *)username());
435
444
void
436
445
BasicUser::extractPassword()
437
446
{
438
 
    passwd = cleartext;
 
447
    passwd = strchr(cleartext, ':');
439
448
 
440
 
    if (cleartext == NULL) {
 
449
    if (passwd == NULL) {
441
450
        debugs(29, 4, "authenticateBasicDecodeAuth: no password in proxy authorization header '" << httpAuthHeader << "'");
442
451
        passwd = NULL;
443
452
        currentRequest->setDenyMessage ("no password was present in the HTTP [proxy-]authorization header. This is most likely a browser bug");
444
 
    } else if (*cleartext == '\0') {
445
 
        debugs(29, 4, "authenticateBasicDecodeAuth: Disallowing empty password,user is '" << username() << "'");
446
 
        passwd = NULL;
447
 
        currentRequest->setDenyMessage ("Request denied because you provided an empty password. Users MUST have a password.");
 
453
    } else {
 
454
        ++passwd;
 
455
        if (*passwd == '\0') {
 
456
            debugs(29, 4, "authenticateBasicDecodeAuth: Disallowing empty password,user is '" << username() << "'");
 
457
            passwd = NULL;
 
458
            currentRequest->setDenyMessage ("Request denied because you provided an empty password. Users MUST have a password.");
 
459
        } else {
 
460
            passwd = xstrndup(passwd, USER_IDENT_SZ);
 
461
        }
448
462
    }
449
 
 
450
 
    if (passwd)
451
 
        passwd = xstrndup(cleartext, USER_IDENT_SZ);
452
 
 
453
 
    cleartext = NULL;
454
463
}
455
464
 
456
465
void