[project @ 2003-10-26 00:09:27 by jmb]

Fix bug involving while loop exiting early.
Move the xstrdup of the realm into riscos/401login.c

svn path=/import/netsurf/; revision=389
This commit is contained in:
John Mark Bell 2003-10-26 00:09:27 +00:00
parent ab8edd9da4
commit f07a47d252
3 changed files with 23 additions and 19 deletions

View File

@ -558,7 +558,7 @@ bool fetch_process_headers(struct fetch *f)
/* handle HTTP 401 (Authentication errors) */
if (http_code == 401) {
f->callback(FETCH_AUTH, f->p, xstrdup(f->realm),0);
f->callback(FETCH_AUTH, f->p, f->realm,0);
return true;
}

View File

@ -5,7 +5,7 @@
* Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk>
*/
//#define NDEBUG
#define NDEBUG
#include <assert.h>
#include <string.h>
@ -67,6 +67,7 @@ struct login *login_list_get(char *host) {
struct login *nli;
char *temp, *temphost;
char *i;
int reached_scheme = 0;
if (host == NULL)
return NULL;
@ -74,8 +75,10 @@ struct login *login_list_get(char *host) {
temphost = get_host_from_url(host);
temp = xstrdup(host);
/* Smallest thing to check for is the scheme + host name + trailing '/'
* So make sure we've got that at least
*/
if (strlen(temphost) > strlen(temp)) {
LOG(("here"));
temp = get_host_from_url(host);
}
@ -86,7 +89,7 @@ struct login *login_list_get(char *host) {
* This allows multiple realms (and login details) per host.
* Only one set of login details per realm are allowed.
*/
do {
do {
LOG(("%s, %d", temp, strlen(temp)));
@ -94,25 +97,26 @@ struct login *login_list_get(char *host) {
(strcasecmp(nli->host, temp)!=0);
nli = nli->next) ;
if (temp[strlen(temp)-1] == '/') {
temp[strlen(temp)-1] = 0;
}
i = strrchr(temp, '/');
if (temp[(i-temp)-1] != '/') /* reached the scheme? */
temp[(i-temp)+1] = 0;
else {
xfree(temphost);
return NULL;
}
if (nli != loginlist) {
LOG(("Got %s", nli->host));
xfree(temphost);
return nli;
}
} while (strcasecmp(temp, temphost) != 0);
else {
if (temp[strlen(temp)-1] == '/') {
temp[strlen(temp)-1] = 0;
}
i = strrchr(temp, '/');
if (temp[(i-temp)-1] != '/') /* reached the scheme? */
temp[(i-temp)+1] = 0;
else {
reached_scheme = 1;
}
}
} while (reached_scheme == 0);
xfree(temphost);
return NULL;

View File

@ -84,7 +84,7 @@ void ro_gui_401login_open(char *host, char* realm, char *fetchurl)
dialog_401->icons[ICON_401LOGIN_HOST].data.indirected_text.size =
strlen(host) + 1;
dialog_401->icons[ICON_401LOGIN_REALM].data.indirected_text.text =
realm;
xstrdup(realm);
dialog_401->icons[ICON_401LOGIN_REALM].data.indirected_text.size =
strlen(realm) + 1;
dialog_401->icons[ICON_401LOGIN_USERNAME].data.indirected_text.text =