summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2003-10-26 00:09:27 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2003-10-26 00:09:27 +0000
commitf07a47d25202eb4b018cc2b81d9275dcd175049b (patch)
treea8c1204b7436f311c88307d4dea217280e677613 /desktop
parentab8edd9da4ec6766dfb07acd25bea5c3f503c1e3 (diff)
downloadnetsurf-f07a47d25202eb4b018cc2b81d9275dcd175049b.tar.gz
netsurf-f07a47d25202eb4b018cc2b81d9275dcd175049b.tar.bz2
[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
Diffstat (limited to 'desktop')
-rw-r--r--desktop/loginlist.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/desktop/loginlist.c b/desktop/loginlist.c
index 9089ae287..639865a7b 100644
--- a/desktop/loginlist.c
+++ b/desktop/loginlist.c
@@ -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;