struct auth_entry *add_auth_entry( struct uri *uri, unsigned char *realm, unsigned char *nonce, unsigned char *opaque, unsigned int digest ) { int eax; int edx; struct auth_entry *entry; if ( find_auth_entry( uri, realm ) == 0 ) { entry = (struct auth_entry*)mem_calloc( 1, 116 ); if ( mem_calloc( 1, 116 ) == 0 ) { return &entry[0]; } uri->object.refcount = uri->object.refcount; *(int*)(mem_calloc( 1, 116 ) + 12) = uri[0]; if ( realm ) { *(int*)(mem_calloc( 1, 116 ) + 16) = stracpy( realm ); if ( mem_calloc( 1, 116 ) + 16 == 0 ) { mem_free( &ecx ); return &entry[0]; } } set_auth_user( &ecx, &uri[0] ); set_auth_password( ebp_28, &uri[0] ); *(int*)(ebp_28 + 28) = eax; if ( ebp_28 + 28 == 0 ) { done_auth_entry( &ecx ); return &entry[0]; } *(int*)(ecx + 4) = auth_entry_list.next; ecx = auth_entry_list.next; auth_entry_list.next = &ecx; *(int*)(ecx + 4) = ecx; if ( nonce ) { auth_entry_list.next[6] = stracpy( nonce ); if ( auth_entry_list.next + 4 + 20 == 0 ) { del_auth_entry( &ecx ); return &entry[0]; } } if ( opaque ) { *(int*)(ebp_28 + 24) = stracpy( opaque ); if ( ebp_28 + 24 == 0 ) { del_auth_entry( &ecx ); return &entry[0]; } } auth_entry_list.next[29] = ( *(char*)(auth_entry_list.next + 4 + 112) & -5 ) | ( ( (int)digest/*.1_1of4*/ & 1 ) << 2 ); } else { if ( ( ( *(char*)(find_auth_entry( uri, realm ) + 112) & 1 ) & 255 ) == 0 ) { if ( (unsigned char)( realm != 0 ) == ( *(int*)(entry[0].next + 16) != 0 ) ) { if ( ( ( realm != 0 ) & 255 ) && ebp_41 && stracpy( opaque ) ) entry->realm[0] = entry->realm; else { if ( entry->user[0] && uri->user && uri->bits_at_40/*.3_4of4*/ ) { errfile = "/home/naftali/source/elinks-0.12~pre5/src/protocol/auth/auth.c"; errline = 185; if ( elinks_strlcmp( &entry->user[0], -1, uri->user, uri->bits_at_40/*.3_4of4*/ ) == 0 ) { if ( entry->password[0] && uri->password && uri->bits_at_44/*.1_2of4*/ ) { errfile = "/home/naftali/source/elinks-0.12~pre5/src/protocol/auth/auth.c"; errline = 192; if ( elinks_strlcmp( &entry->password[0], -1, uri->password, (int)uri->bits_at_44/*.1_2of4*/ ) ) goto B36; } B36: entry->bits_at_112/*.1_1of4*/ &= 253; set_auth_password( &entry[0], &uri[0] ); } } entry->bits_at_112/*.1_1of4*/ &= 253; set_auth_user( &entry[0], &uri[0] ); } } entry->bits_at_112/*.1_1of4*/ = (int)entry->bits_at_112/*.1_1of4*/ & -3; if ( entry->realm ) mem_free( (void*)entry->realm ); entry->realm = 0; if ( ( realm != 0 ) & 255 ) { entry->realm = stracpy( realm ); if ( entry->realm ) { if ( nonce ) { if ( entry->nonce ) mem_free( (void*)entry->nonce ); entry->nonce = stracpy( nonce ); if ( entry->nonce == 0 ) goto B23; } if ( opaque ) { if ( entry->opaque ) mem_free( (void*)entry->opaque ); entry->opaque = stracpy( opaque ); if ( entry->opaque == 0 ) { del_auth_entry( &entry[0] ); uri = &uri[0]; return 0; } } entry->bits_at_112/*.1_1of4*/ = ( *(char*)(entry[0].next + 112) & -5 ) | ( ( (int)digest/*.1_1of4*/ & 1 ) << 2 ); } B23: &entry[0] = 0; del_auth_entry( &entry[0] ); return &entry[0]; } } else { return 0; } } if ( !( ( entry->bits_at_112/*.1_1of4*/ & 2 ) & 255 ) && entry->realm ) { add_questions_entry( &do_auth_dialog, (void*)entry[0].next ); return &entry[0]; } return &entry[0]; }
/* Returns the new entry or updates an existing one. Sets the @valid member if * updating is required so it can be tested if the user should be queried. */ struct auth_entry * add_auth_entry(struct uri *uri, unsigned char *realm, unsigned char *nonce, unsigned char *opaque, unsigned int digest) { struct auth_entry *entry; #ifdef DEBUG_HTTP_AUTH DBG("add_auth_entry: newurl=%s realm=%s uri=%p", newurl, realm, uri); #endif /* Is host/realm already known ? */ entry = find_auth_entry(uri, realm); if (entry) { /* Waiting for user/pass in dialog. */ if (entry->blocked) return NULL; /* In order to use an existing entry it has to match exactly. * This is done step by step. If something isn't equal the * entry is updated and marked as invalid. */ /* If only one realm is defined or they don't compare. */ if ((!!realm ^ !!entry->realm) || (realm && entry->realm && strcmp(realm, entry->realm))) { entry->valid = 0; mem_free_set(&entry->realm, NULL); if (realm) { entry->realm = stracpy(realm); if (!entry->realm) { del_auth_entry(entry); return NULL; } if (nonce) { mem_free_set(&entry->nonce, stracpy(nonce)); if (!entry->nonce) { del_auth_entry(entry); return NULL; } } if (opaque) { mem_free_set(&entry->opaque, stracpy(opaque)); if (!entry->opaque) { del_auth_entry(entry); return NULL; } } entry->digest = digest; } } if (!*entry->user || (!uri->user || !uri->userlen || strlcmp(entry->user, -1, uri->user, uri->userlen))) { entry->valid = 0; set_auth_user(entry, uri); } if (!*entry->password || (!uri->password || !uri->passwordlen || strlcmp(entry->password, -1, uri->password, uri->passwordlen))) { entry->valid = 0; set_auth_password(entry, uri); } } else { /* Create a new entry. */ entry = init_auth_entry(uri, realm); if (!entry) return NULL; add_to_list(auth_entry_list, entry); if (nonce) { entry->nonce = stracpy(nonce); if (!entry->nonce) { del_auth_entry(entry); return NULL; } } if (opaque) { entry->opaque = stracpy(opaque); if (!entry->opaque) { del_auth_entry(entry); return NULL; } } entry->digest = digest; } /* Only pop up question if one of the protocols requested it */ if (entry && !entry->valid && entry->realm) add_questions_entry(do_auth_dialog, entry); return entry; }