about summary refs log tree commit diff stats
path: root/WWW
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2013-05-01 01:00:38 -0400
committerThomas E. Dickey <dickey@invisible-island.net>2013-05-01 01:00:38 -0400
commit81905f18dc0594e372cf38cfb0e0b71b69849a43 (patch)
tree8eb23ef6f907e1a4f53bd7c2247522b077037e63 /WWW
parent7827f0bdba0c75376e59443975f3638df4cce044 (diff)
downloadlynx-snapshots-81905f18dc0594e372cf38cfb0e0b71b69849a43.tar.gz
snapshot of project "lynx", label v2-8-8dev-15b
Diffstat (limited to 'WWW')
-rw-r--r--WWW/Library/Implementation/HTAABrow.c36
-rw-r--r--WWW/Library/Implementation/HTAAUtil.c4
-rw-r--r--WWW/Library/Implementation/HTAccess.c20
-rw-r--r--WWW/Library/Implementation/HTFTP.c109
-rw-r--r--WWW/Library/Implementation/HTFile.c30
-rw-r--r--WWW/Library/Implementation/HTFinger.c8
-rw-r--r--WWW/Library/Implementation/HTGopher.c12
-rw-r--r--WWW/Library/Implementation/HTList.c26
-rw-r--r--WWW/Library/Implementation/HTMIME.c37
-rw-r--r--WWW/Library/Implementation/HTRules.c4
-rw-r--r--WWW/Library/Implementation/HTTP.c14
-rw-r--r--WWW/Library/Implementation/HTTelnet.c4
-rw-r--r--WWW/Library/Implementation/HTUtils.h4
13 files changed, 151 insertions, 157 deletions
diff --git a/WWW/Library/Implementation/HTAABrow.c b/WWW/Library/Implementation/HTAABrow.c
index 3e25deaf..bb32c94b 100644
--- a/WWW/Library/Implementation/HTAABrow.c
+++ b/WWW/Library/Implementation/HTAABrow.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTAABrow.c,v 1.34 2010/09/24 08:27:42 tom Exp $
+ * $LynxId: HTAABrow.c,v 1.38 2013/04/30 09:11:00 tom Exp $
  *
  * MODULE							HTAABrow.c
  *		BROWSER SIDE ACCESS AUTHORIZATION MODULE
@@ -638,7 +638,7 @@ static char *compose_auth_string(HTAAScheme scheme, HTAASetup * setup, int IsPro
 		   NonNull(thePort));
 	FREE(proxiedHost);
 	FREE(thePort);
-	username = realm->username;
+	StrAllocCopy(username, realm->username);
 	password = NULL;
 	HTPromptUsernameAndPassword(msg, &username, &password, IsProxy);
 
@@ -1058,6 +1058,7 @@ BOOL HTAA_shouldRetryWithAuth(char *start_of_headers,
     HTAssocList **scheme_specifics = NULL;
     char *ctemplate = NULL;
     char *temp = NULL;
+    BOOL result = NO;
 
     /*
      * Setup atexit() freeing if not done already.  - FM
@@ -1147,12 +1148,12 @@ BOOL HTAA_shouldRetryWithAuth(char *start_of_headers,
 	     * No proxy authorization valid
 	     */
 	    proxy_setup = NULL;
-	    return NO;
+	    result = NO;
 	}
 	/*
 	 * Doing it for proxy.  -AJL
 	 */
-	if (proxy_setup && proxy_setup->server) {
+	else if (proxy_setup && proxy_setup->server) {
 	    /*
 	     * We have already tried with proxy authorization.  Either we don't
 	     * have access or username or password was misspelled.
@@ -1164,13 +1165,14 @@ BOOL HTAA_shouldRetryWithAuth(char *start_of_headers,
 
 	    if (NO == HTConfirm(AUTH_FAILED_PROMPT)) {
 		proxy_setup = NULL;
-		return NO;
+		result = NO;
 	    } else {
 		/*
 		 * Re-ask username+password (if misspelled).
 		 */
+		HTList_delete(valid_schemes);
 		proxy_setup->retry = YES;
-		return YES;
+		result = YES;
 	    }
 	} else {
 	    /*
@@ -1196,21 +1198,19 @@ BOOL HTAA_shouldRetryWithAuth(char *start_of_headers,
 	    FREE(ctemplate);
 
 	    HTAlert(gettext("Proxy authorization required -- retrying"));
-	    return YES;
+	    result = YES;
 	}
-	/* Never reached */
     }
     /*
      * Normal WWW authorization.
      */
-    if (num_schemes == 0) {
+    else if (num_schemes == 0) {
 	/*
 	 * No authorization valid.
 	 */
 	current_setup = NULL;
-	return NO;
-    }
-    if (current_setup && current_setup->server) {
+	result = NO;
+    } else if (current_setup && current_setup->server) {
 	/*
 	 * So we have already tried with WWW authorization.  Either we don't
 	 * have access or username or password was misspelled.
@@ -1222,13 +1222,13 @@ BOOL HTAA_shouldRetryWithAuth(char *start_of_headers,
 
 	if (NO == HTConfirm(AUTH_FAILED_PROMPT)) {
 	    current_setup = NULL;
-	    return NO;
+	    result = NO;
 	} else {
 	    /*
 	     * Re-ask username+password (if misspelled).
 	     */
 	    current_setup->retry = YES;
-	    return YES;
+	    result = YES;
 	}
     } else {
 	/*
@@ -1254,9 +1254,13 @@ BOOL HTAA_shouldRetryWithAuth(char *start_of_headers,
 	FREE(ctemplate);
 
 	HTAlert(gettext("Access without authorization denied -- retrying"));
-	return YES;
+	result = YES;
+    }
+
+    if (result == NO) {
+	HTList_delete(valid_schemes);
     }
-    /* Never reached */
+    return result;
 }
 
 /*
diff --git a/WWW/Library/Implementation/HTAAUtil.c b/WWW/Library/Implementation/HTAAUtil.c
index 8a6caab6..2113b400 100644
--- a/WWW/Library/Implementation/HTAAUtil.c
+++ b/WWW/Library/Implementation/HTAAUtil.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTAAUtil.c,v 1.31 2010/09/24 23:51:22 tom Exp $
+ * $LynxId: HTAAUtil.c,v 1.34 2013/04/30 23:16:09 tom Exp $
  *
  * MODULE							HTAAUtil.c
  *		COMMON PARTS OF ACCESS AUTHORIZATION MODULE
@@ -557,6 +557,8 @@ char *HTAA_getUnfoldedLine(void)
 		in_soc = -1;
 		return line;
 	    }
+	    if (count > (int) buffer_length)
+		count = (int) buffer_length;
 	    start_pointer = buffer;
 	    end_pointer = buffer + count;
 	    *end_pointer = '\0';
diff --git a/WWW/Library/Implementation/HTAccess.c b/WWW/Library/Implementation/HTAccess.c
index 5bfcce4e..cfb5a450 100644
--- a/WWW/Library/Implementation/HTAccess.c
+++ b/WWW/Library/Implementation/HTAccess.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTAccess.c,v 1.77 2012/02/23 00:39:40 tom Exp $
+ * $LynxId: HTAccess.c,v 1.78 2013/04/30 22:59:03 tom Exp $
  *
  *		Access Manager					HTAccess.c
  *		==============
@@ -858,7 +858,7 @@ static BOOL HTLoadDocument(const char *full_address,	/* may include #fragment */
 	 * (3) we are repositioning within the currently loaded document based
 	 * on the target anchor's address (URL_Reference).
 	 *
-	 * If DONT_TRACK_INTERNAL_LINKS is defined, HText_AreDifferent() is
+	 * If track_internal_links is false, HText_AreDifferent() is
 	 * used to determine whether (3) applies.  If the target address
 	 * differs from that of the current document only by a fragment and the
 	 * target address has an appended fragment, repositioning without
@@ -873,7 +873,7 @@ static BOOL HTLoadDocument(const char *full_address,	/* may include #fragment */
 	 * (e.g., user requested RELOAD, or HTTP response with no-cache header
 	 * and we are not overriding).
 	 *
-	 * If DONT_TRACK_INTERNAL_LINKS is undefined, a target address that
+	 * If track_internal_links is true, a target address that
 	 * points to the same URL as the current document may still result in
 	 * reloading, depending on whether the original URL-Reference was given
 	 * as an internal link in the context of the previously loaded
@@ -897,14 +897,12 @@ static BOOL HTLoadDocument(const char *full_address,	/* may include #fragment */
 	 */
 	if ((reloading != REAL_RELOAD) &&
 	    (LYoverride_no_cache ||
-#ifdef DONT_TRACK_INTERNAL_LINKS
-	     !HText_hasNoCacheSet(text) ||
-	     !HText_AreDifferent(anchor, full_address)
-#else
-	     ((LYinternal_flag || !HText_hasNoCacheSet(text)) &&
-	      !isLYNXIMGMAP(full_address))
-#endif /* TRACK_INTERNAL_LINKS */
-	    )) {
+	     ((!track_internal_links &&
+	       (!HText_hasNoCacheSet(text) ||
+		!HText_AreDifferent(anchor, full_address))) ||
+	      (track_internal_links &&
+	       (((LYinternal_flag || !HText_hasNoCacheSet(text)) &&
+		 !isLYNXIMGMAP(full_address))))))) {
 	    CTRACE((tfp, "HTAccess: Document already in memory.\n"));
 	    HText_select(text);
 
diff --git a/WWW/Library/Implementation/HTFTP.c b/WWW/Library/Implementation/HTFTP.c
index e8dea73b..b2edabd1 100644
--- a/WWW/Library/Implementation/HTFTP.c
+++ b/WWW/Library/Implementation/HTFTP.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTFTP.c,v 1.106 2012/11/15 23:51:23 tom Exp $
+ * $LynxId: HTFTP.c,v 1.114 2013/01/05 01:35:12 tom Exp $
  *
  *			File Transfer Protocol (FTP) Client
  *			for a WorldWideWeb browser
@@ -351,9 +351,13 @@ char *HTVMS_name(const char *nn,
 	HTSprintf0(&vmsname, "%s%s:[%s]%s",
 		   nodename, filename + 1, second + 1, last + 1);
 	*second = *last = '/';	/* restore filename */
-	for (p = strchr(vmsname, '['); *p != ']'; p++)
-	    if (*p == '/')
-		*p = '.';	/* Convert dir sep.  to dots */
+	if ((p = strchr(vmsname, '[')) != 0) {
+	    while (*p != '\0' && *p != ']') {
+		if (*p == '/')
+		    *p = '.';	/* Convert dir sep.  to dots */
+		++p;
+	    }
+	}
     }
     FREE(nodename);
     FREE(filename);
@@ -764,6 +768,15 @@ static void set_unix_dirstyle(eServerType *ServerType, BOOLEAN *UseList)
     }
 }
 
+#define CheckForInterrupt(msg) \
+	if (status == HT_INTERRUPTED) { \
+	    CTRACE((tfp, "HTFTP: Interrupted %s.\n", msg)); \
+	    _HTProgress(CONNECTION_INTERRUPTED); \
+	    NETCLOSE(control->socket); \
+	    control->socket = -1; \
+	    return HT_INTERRUPTED; \
+	}
+
 /*	Get a valid connection to the host
  *	----------------------------------
  *
@@ -821,13 +834,13 @@ static int get_connection(const char *arg,
     }
     con->socket = -1;
 
-    if (!arg)
+    if (isEmpty(arg)) {
+	free(con);
 	return -1;		/* Bad if no name specified     */
-    if (!*arg)
-	return -1;		/* Bad if name had zero length  */
+    }
 
-/* Get node name:
-*/
+    /* Get node name:
+     */
     CTRACE((tfp, "get_connection(%s)\n", arg));
     {
 	char *p1 = HTParse(arg, "", PARSE_HOST);
@@ -914,17 +927,11 @@ static int get_connection(const char *arg,
     HTInitInput(control->socket);
     init_help_message_cache();	/* Clear the login message buffer. */
 
-/*	Now we log in		Look up username, prompt for pw.
-*/
+    /*  Now we log in           Look up username, prompt for pw.
+     */
     status = response((char *) 0);	/* Get greeting */
+    CheckForInterrupt("at beginning of login");
 
-    if (status == HT_INTERRUPTED) {
-	CTRACE((tfp, "HTFTP: Interrupted at beginning of login.\n"));
-	_HTProgress(CONNECTION_INTERRUPTED);
-	NETCLOSE(control->socket);
-	control->socket = -1;
-	return HT_INTERRUPTED;
-    }
     server_type = GENERIC_SERVER;	/* reset */
     if (status == 2) {		/* Send username */
 	char *cp;		/* look at greeting text */
@@ -947,13 +954,7 @@ static int get_connection(const char *arg,
 			    ? username
 			    : "anonymous");
 
-	if (status == HT_INTERRUPTED) {
-	    CTRACE((tfp, "HTFTP: Interrupted while sending username.\n"));
-	    _HTProgress(CONNECTION_INTERRUPTED);
-	    NETCLOSE(control->socket);
-	    control->socket = -1;
-	    return HT_INTERRUPTED;
-	}
+	CheckForInterrupt("while sending username");
     }
     if (status == 3) {		/* Send password */
 	if (password) {
@@ -1001,26 +1002,13 @@ static int get_connection(const char *arg,
 	}
 	status = response(command);
 	FREE(command);
-	if (status == HT_INTERRUPTED) {
-	    CTRACE((tfp, "HTFTP: Interrupted while sending password.\n"));
-	    _HTProgress(CONNECTION_INTERRUPTED);
-	    NETCLOSE(control->socket);
-	    control->socket = -1;
-	    return HT_INTERRUPTED;
-	}
+	CheckForInterrupt("while sending password");
     }
     FREE(username);
 
     if (status == 3) {
 	status = send_cmd_1("ACCT noaccount");
-	if (status == HT_INTERRUPTED) {
-	    CTRACE((tfp, "HTFTP: Interrupted while sending password.\n"));
-	    _HTProgress(CONNECTION_INTERRUPTED);
-	    NETCLOSE(control->socket);
-	    control->socket = -1;
-	    return HT_INTERRUPTED;
-	}
-
+	CheckForInterrupt("while sending password");
     }
     if (status != 2) {
 	CTRACE((tfp, "HTFTP: Login fail: %s", response_text));
@@ -1127,20 +1115,6 @@ static int get_connection(const char *arg,
 	get_ftp_pwd(&server_type, &use_list);
     }
 
-/*  Now we inform the server of the port number we will listen on
-*/
-#ifdef NOTREPEAT_PORT
-    {
-	int status = response(port_command);
-
-	if (status != 2) {
-	    if (control->socket)
-		close_connection(control->socket);
-	    return -status;	/* Bad return */
-	}
-	CTRACE((tfp, "HTFTP: Port defined.\n"));
-    }
-#endif /* NOTREPEAT_PORT */
     return con->socket;		/* Good return */
 }
 
@@ -1319,8 +1293,10 @@ static int get_listen_socket(void)
 	    status = getsockname(control->socket,
 				 (struct sockaddr *) &soc_address,
 				 &address_length);
-	if (status < 0)
+	if (status < 0) {
+	    close(new_socket);
 	    return HTInetStatus("getsockname");
+	}
 #ifdef INET6
 	CTRACE((tfp, "HTFTP: This host is %s\n",
 		HTInetString((void *) soc_in)));
@@ -1349,8 +1325,10 @@ static int get_listen_socket(void)
 	    /* Cast to generic sockaddr */
 			  SOCKADDR_LEN(soc_address)
 		);
-	if (status < 0)
+	if (status < 0) {
+	    close(new_socket);
 	    return HTInetStatus("bind");
+	}
 
 	address_length = sizeof(soc_address);
 #ifdef SOCKS
@@ -1363,8 +1341,10 @@ static int get_listen_socket(void)
 	    status = getsockname(new_socket,
 				 (struct sockaddr *) &soc_address,
 				 &address_length);
-	if (status < 0)
+	if (status < 0) {
+	    close(new_socket);
 	    return HTInetStatus("getsockname");
+	}
     }
 #endif /* POLL_PORTS */
 
@@ -1790,7 +1770,7 @@ static void parse_dls_line(char *line,
 		StrAllocCopy(entry_info->type, "");
 	} else {
 	    StrAllocCopy(entry_info->filename, line);
-	    if (cps && cps != line && *(cps - 1) == '/')
+	    if (cps != line && *(cps - 1) == '/')
 		StrAllocCopy(entry_info->type, ENTRY_IS_DIRECTORY);
 	    else
 		StrAllocCopy(entry_info->type, "");
@@ -2345,7 +2325,7 @@ static EntryInfo *parse_dir_entry(char *entry,
 	    /* if still unchanged... */
 	    parse_dls_line(entry, entry_info, pspilledname);
 
-	    if (!entry_info->filename || *entry_info->filename == '\0') {
+	    if (isEmpty(entry_info->filename)) {
 		entry_info->display = FALSE;
 		return (entry_info);
 	    }
@@ -2577,7 +2557,11 @@ static EntryInfo *parse_dir_entry(char *entry,
     }
 #endif
 
-    if (entry_info->filename && strlen(entry_info->filename) > 3) {
+    if (isEmpty(entry_info->filename)) {
+	entry_info->display = FALSE;
+	return (entry_info);
+    }
+    if (strlen(entry_info->filename) > 3) {
 	if (((cp = strrchr(entry_info->filename, '.')) != NULL &&
 	     0 == strncasecomp(cp, ".me", 3)) &&
 	    (cp[3] == '\0' || cp[3] == ';')) {
@@ -2980,6 +2964,7 @@ static void LYListFmtParse(const char *fmtstr,
     FREE(str);
 }
 #endif /* LONG_LIST */
+
 /*	Read a directory into an hypertext object from the data socket
  *	--------------------------------------------------------------
  *
@@ -3080,6 +3065,7 @@ static int read_directory(HTParentAnchor *parent,
 		    ABORT_TARGET;
 		    HTBTreeAndObject_free(bt);
 		    FREE(spilledname);
+		    HTChunkFree(chunk);
 		    return HT_INTERRUPTED;
 		}
 	    }
@@ -3101,6 +3087,7 @@ static int read_directory(HTParentAnchor *parent,
 			ABORT_TARGET;
 			HTBTreeAndObject_free(bt);
 			FREE(spilledname);
+			HTChunkFree(chunk);
 			return HT_INTERRUPTED;
 		    }
 		} else if ((char) ic == CR || (char) ic == LF) {	/* Terminator? */
@@ -3433,7 +3420,7 @@ static int setup_connection(const char *name,
 		    ;		/* null body */
 		}
 		for ( /*nothing */ ;
-		     *p && *p && *p != '(';
+		     *p && *p != '(';
 		     p++) {	/*) */
 		    ;		/* null body */
 		}
diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c
index 301214aa..a0640512 100644
--- a/WWW/Library/Implementation/HTFile.c
+++ b/WWW/Library/Implementation/HTFile.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTFile.c,v 1.132 2012/08/15 22:10:08 tom Exp $
+ * $LynxId: HTFile.c,v 1.135 2013/05/01 00:09:25 tom Exp $
  *
  *			File Access				HTFile.c
  *			===========
@@ -1169,10 +1169,10 @@ void LYGetFileInfo(const char *filename,
     LYLocalFileToURL(&Aname, Afn);
     file_anchor = HTAnchor_findSimpleAddress(Aname);
 
-    file_csname = file_anchor->charset;
     format = HTFileFormat(filename, &myEnc, pdesc);
     format = HTCharsetFormat(format, file_anchor, UCLYhndl_HTFile_for_unspec);
     file_cs = HTAnchor_getUCLYhndl(file_anchor, UCT_STAGE_MIME);
+    file_csname = file_anchor->charset;
     if (!file_csname) {
 	if (file_cs >= 0)
 	    file_csname = LYCharSet_UC[file_cs].MIMEname;
@@ -2289,12 +2289,14 @@ static BOOL sniffStream(FILE *fp, char *buffer, size_t needed)
     long offset = ftell(fp);
     BOOL result = FALSE;
 
-    if (fread(buffer, sizeof(char), needed, fp) == needed) {
-	result = TRUE;
-    }
-    if (fseek(fp, offset, SEEK_SET) < 0) {
-	CTRACE((tfp, "error seeking in stream\n"));
-	result = FALSE;
+    if (offset >= 0) {
+	if (fread(buffer, sizeof(char), needed, fp) == needed) {
+	    result = TRUE;
+	}
+	if (fseek(fp, offset, SEEK_SET) < 0) {
+	    CTRACE((tfp, "error seeking in stream\n"));
+	    result = FALSE;
+	}
     }
     return result;
 }
@@ -2385,6 +2387,7 @@ static int decompressAndParse(HTParentAnchor *anchor,
     char *localname = filename;
     int bin;
     FILE *fp;
+    int result = FALSE;
 
 #ifdef VMS
     /*
@@ -2443,6 +2446,7 @@ static int decompressAndParse(HTParentAnchor *anchor,
 	    if (isDOWNLOAD(cftGzip)) {
 		if (isGzipStream(fp)) {
 		    fclose(fp);
+		    fp = 0;
 		    gzfp = gzopen(localname, BIN_R);
 
 		    CTRACE((tfp, "HTLoadFile: gzopen of `%s' gives %p\n",
@@ -2464,6 +2468,7 @@ static int decompressAndParse(HTParentAnchor *anchor,
 	    if (isDOWNLOAD(cftBzip2)) {
 		if (isBzip2Stream(fp)) {
 		    fclose(fp);
+		    fp = 0;
 		    bzfp = BZ2_bzopen(localname, BIN_R);
 
 		    CTRACE((tfp, "HTLoadFile: bzopen of `%s' gives %p\n",
@@ -2520,6 +2525,7 @@ static int decompressAndParse(HTParentAnchor *anchor,
 		if (strcmp(format_out->name, "www/download") != 0) {
 		    if (isGzipStream(fp)) {
 			fclose(fp);
+			fp = 0;
 			gzfp = gzopen(localname, BIN_R);
 
 			CTRACE((tfp, "HTLoadFile: gzopen of `%s' gives %p\n",
@@ -2537,6 +2543,7 @@ static int decompressAndParse(HTParentAnchor *anchor,
 		if (strcmp(format_out->name, "www/download") != 0) {
 		    if (isBzip2Stream(fp)) {
 			fclose(fp);
+			fp = 0;
 			bzfp = BZ2_bzopen(localname, BIN_R);
 
 			CTRACE((tfp, "HTLoadFile: bzopen of `%s' gives %p\n",
@@ -2621,11 +2628,14 @@ static int decompressAndParse(HTParentAnchor *anchor,
 #endif /* USE_ZLIB || USE_BZLIB */
 	{
 	    *statusp = HTParseFile(format, format_out, anchor, fp, sink);
+	}
+	if (fp != 0) {
 	    fclose(fp);
+	    fp = 0;
 	}
-	return TRUE;
+	result = TRUE;
     }				/* If successful open */
-    return FALSE;
+    return result;
 }
 
 /*	Load a document.
diff --git a/WWW/Library/Implementation/HTFinger.c b/WWW/Library/Implementation/HTFinger.c
index 0dfc7a68..ebf18db7 100644
--- a/WWW/Library/Implementation/HTFinger.c
+++ b/WWW/Library/Implementation/HTFinger.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTFinger.c,v 1.29 2011/05/24 09:21:13 tom Exp $
+ * $LynxId: HTFinger.c,v 1.30 2013/01/04 21:40:19 tom Exp $
  *
  *			FINGER ACCESS				HTFinger.c
  *			=============
@@ -163,11 +163,7 @@ static int response(char *command,
     PUTS(sitename);
     END(HTML_EM);
     PUTS(": ");
-    if (command) {
-	StrAllocCopy(cmd, command);
-    } else {
-	StrAllocCopy(cmd, "");
-    }
+    StrAllocCopy(cmd, command);
     for (i = ((int) strlen(cmd) - 1); i >= 0; i--) {
 	if (cmd[i] == LF || cmd[i] == CR) {
 	    cmd[i] = '\0';
diff --git a/WWW/Library/Implementation/HTGopher.c b/WWW/Library/Implementation/HTGopher.c
index 3ce376d6..57492b1d 100644
--- a/WWW/Library/Implementation/HTGopher.c
+++ b/WWW/Library/Implementation/HTGopher.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTGopher.c,v 1.56 2012/11/17 01:33:36 tom Exp $
+ * $LynxId: HTGopher.c,v 1.58 2013/01/04 21:10:29 tom Exp $
  *
  *			GOPHER ACCESS				HTGopher.c
  *			=============
@@ -742,6 +742,7 @@ static void free_CSOfields(void)
  */
 static void interpret_cso_key(const char *key,
 			      char *buf,
+			      size_t bufsize,
 			      int *length,
 			      CSOformgen_context * ctx,
 			      HTStream *Target)
@@ -856,7 +857,7 @@ static void interpret_cso_key(const char *key,
 
 	while (*key && (*key != ')')) {
 	    buf[out++] = (*key++);
-	    if (out > sizeof(buf) - 2) {
+	    if (out > bufsize - 2) {
 		buf[out] = '\0';
 		(*Target->isa->put_block) (Target, buf, (int) strlen(buf));
 		out = 0;
@@ -1087,6 +1088,7 @@ static int parse_cso_fields(char *buf,
 static int generate_cso_form(char *host,
 			     int port,
 			     char *buf,
+			     size_t bufsize,
 			     HTStream *Target)
 {
     int i, j, length;
@@ -1159,7 +1161,7 @@ static int generate_cso_form(char *host,
 		 */
 		ctx.cur_line = i;
 		ctx.cur_off = j;
-		interpret_cso_key(key, buf, &length, &ctx, Target);
+		interpret_cso_key(key, buf, bufsize, &length, &ctx, Target);
 		i = ctx.cur_line;
 		j = ctx.cur_off;
 		line = ctemplate[i];
@@ -1202,7 +1204,7 @@ static int generate_cso_form(char *host,
 		 * Non-command text, add to output buffer.
 		 */
 		buf[out++] = line[j];
-		if (out > (sizeof(buf) - 3)) {
+		if (out > (bufsize - 3)) {
 		    buf[out] = '\0';
 		    (*Target->isa->put_block) (Target, buf, (int) strlen(buf));
 		    out = 0;
@@ -1537,7 +1539,7 @@ static int HTLoadCSO(const char *arg,
     }
     anAnchor->safe = TRUE;
     if (isBEmpty(anAnchor->post_data)) {
-	generate_cso_form(host, port, buf, Target);
+	generate_cso_form(host, port, buf, sizeof(buf), Target);
 	(*Target->isa->_free) (Target);
 	FREE(host);
 	NETCLOSE(s);
diff --git a/WWW/Library/Implementation/HTList.c b/WWW/Library/Implementation/HTList.c
index fee62404..996bea3d 100644
--- a/WWW/Library/Implementation/HTList.c
+++ b/WWW/Library/Implementation/HTList.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTList.c,v 1.18 2010/04/29 09:59:31 tom Exp $
+ * $LynxId: HTList.c,v 1.19 2013/01/04 00:31:27 tom Exp $
  *
  *	A small List class					      HTList.c
  *	==================
@@ -263,23 +263,23 @@ void *HTList_removeObjectAt(HTList *me, int position)
     HTList *temp = me;
     HTList *prevNode;
     int pos = position;
+    void *result = NULL;
 
-    if (!temp || pos < 0)
-	return NULL;
-
-    prevNode = temp;
-    while ((temp = temp->next)) {
-	if (pos == 0) {
-	    prevNode->next = temp->next;
+    if (temp != NULL && pos >= 0) {
+	prevNode = temp;
+	while ((temp = temp->next) != NULL) {
+	    if (pos == 0) {
+		prevNode->next = temp->next;
+		result = temp->object;
+		FREE(temp);
+		break;
+	    }
 	    prevNode = temp;
-	    FREE(temp);
-	    return prevNode->object;
+	    pos--;
 	}
-	prevNode = temp;
-	pos--;
     }
 
-    return NULL;		/* Reached the end of the list */
+    return result;
 }
 
 /*	Unlink object from START of list (the Last one inserted
diff --git a/WWW/Library/Implementation/HTMIME.c b/WWW/Library/Implementation/HTMIME.c
index a8e41974..8a420736 100644
--- a/WWW/Library/Implementation/HTMIME.c
+++ b/WWW/Library/Implementation/HTMIME.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTMIME.c,v 1.79 2012/08/22 09:48:46 tom Exp $
+ * $LynxId: HTMIME.c,v 1.84 2013/04/30 08:46:21 tom Exp $
  *
  *			MIME Message Parse			HTMIME.c
  *			==================
@@ -625,7 +625,7 @@ static int dispatchField(HTStream *me)
 	HTMIME_TrimDoubleQuotes(me->value);
 	CTRACE((tfp, "HTMIME: PICKED UP Cache-Control: '%s'\n",
 		me->value));
-	if (!(me->value && *me->value))
+	if (me->value[0] == '\0')
 	    break;
 	/*
 	 * Convert to lowercase and indicate in anchor.  - FM
@@ -687,7 +687,7 @@ static int dispatchField(HTStream *me)
 	HTMIME_TrimDoubleQuotes(me->value);
 	CTRACE((tfp, "HTMIME: PICKED UP Content-Base: '%s'\n",
 		me->value));
-	if (!(me->value && *me->value))
+	if (me->value[0] == '\0')
 	    break;
 	/*
 	 * Indicate in anchor.  - FM
@@ -698,7 +698,7 @@ static int dispatchField(HTStream *me)
 	HTMIME_TrimDoubleQuotes(me->value);
 	CTRACE((tfp, "HTMIME: PICKED UP Content-Disposition: '%s'\n",
 		me->value));
-	if (!(me->value && *me->value))
+	if (me->value[0] == '\0')
 	    break;
 	/*
 	 * Indicate in anchor.  - FM
@@ -747,7 +747,7 @@ static int dispatchField(HTStream *me)
 	HTMIME_TrimDoubleQuotes(me->value);
 	CTRACE((tfp, "HTMIME: PICKED UP Content-Encoding: '%s'\n",
 		me->value));
-	if (!(me->value && *me->value) ||
+	if (me->value[0] == '\0' ||
 	    !strcasecomp(me->value, "identity"))
 	    break;
 	/*
@@ -779,7 +779,7 @@ static int dispatchField(HTStream *me)
 	HTMIME_TrimDoubleQuotes(me->value);
 	CTRACE((tfp, "HTMIME: PICKED UP Content-Language: '%s'\n",
 		me->value));
-	if (!(me->value && *me->value))
+	if (me->value[0] == '\0')
 	    break;
 	/*
 	 * Convert to lowercase and indicate in anchor.  - FM
@@ -791,7 +791,7 @@ static int dispatchField(HTStream *me)
 	HTMIME_TrimDoubleQuotes(me->value);
 	CTRACE((tfp, "HTMIME: PICKED UP Content-Length: '%s'\n",
 		me->value));
-	if (!(me->value && *me->value))
+	if (me->value[0] == '\0')
 	    break;
 	/*
 	 * Convert to integer and indicate in anchor.  - FM
@@ -806,7 +806,7 @@ static int dispatchField(HTStream *me)
 	HTMIME_TrimDoubleQuotes(me->value);
 	CTRACE((tfp, "HTMIME: PICKED UP Content-Location: '%s'\n",
 		me->value));
-	if (!(me->value && *me->value))
+	if (me->value[0] == '\0')
 	    break;
 	/*
 	 * Indicate in anchor.  - FM
@@ -817,7 +817,7 @@ static int dispatchField(HTStream *me)
 	HTMIME_TrimDoubleQuotes(me->value);
 	CTRACE((tfp, "HTMIME: PICKED UP Content-MD5: '%s'\n",
 		me->value));
-	if (!(me->value && *me->value))
+	if (me->value[0] == '\0')
 	    break;
 	/*
 	 * Indicate in anchor.  - FM
@@ -833,7 +833,7 @@ static int dispatchField(HTStream *me)
 	HTMIME_TrimDoubleQuotes(me->value);
 	CTRACE((tfp, "HTMIME: PICKED UP Content-Transfer-Encoding: '%s'\n",
 		me->value));
-	if (!(me->value && *me->value))
+	if (me->value[0] == '\0')
 	    break;
 	/*
 	 * Force the Content-Transfer-Encoding value to all lower case.  - FM
@@ -845,7 +845,7 @@ static int dispatchField(HTStream *me)
 	HTMIME_TrimDoubleQuotes(me->value);
 	CTRACE((tfp, "HTMIME: PICKED UP Content-Type: '%s'\n",
 		me->value));
-	if (!(me->value && *me->value))
+	if (me->value[0] == '\0')
 	    break;
 	/*
 	 * Force the Content-Type value to all lower case and strip spaces and
@@ -864,7 +864,7 @@ static int dispatchField(HTStream *me)
 	HTMIME_TrimDoubleQuotes(me->value);
 	CTRACE((tfp, "HTMIME: PICKED UP Date: '%s'\n",
 		me->value));
-	if (!(me->value && *me->value))
+	if (me->value[0] == '\0')
 	    break;
 	/*
 	 * Indicate in anchor.  - FM
@@ -877,7 +877,7 @@ static int dispatchField(HTStream *me)
 	 */
 	CTRACE((tfp, "HTMIME: PICKED UP ETag: %s\n",
 		me->value));
-	if (!(me->value && *me->value))
+	if (me->value[0] == '\0')
 	    break;
 	/*
 	 * Indicate in anchor.  - FM
@@ -888,7 +888,7 @@ static int dispatchField(HTStream *me)
 	HTMIME_TrimDoubleQuotes(me->value);
 	CTRACE((tfp, "HTMIME: PICKED UP Expires: '%s'\n",
 		me->value));
-	if (!(me->value && *me->value))
+	if (me->value[0] == '\0')
 	    break;
 	/*
 	 * Indicate in anchor.  - FM
@@ -904,7 +904,7 @@ static int dispatchField(HTStream *me)
 	HTMIME_TrimDoubleQuotes(me->value);
 	CTRACE((tfp, "HTMIME: PICKED UP Last-Modified: '%s'\n",
 		me->value));
-	if (!(me->value && *me->value))
+	if (me->value[0] == '\0')
 	    break;
 	/*
 	 * Indicate in anchor.  - FM
@@ -930,7 +930,7 @@ static int dispatchField(HTStream *me)
 	HTMIME_TrimDoubleQuotes(me->value);
 	CTRACE((tfp, "HTMIME: PICKED UP Pragma: '%s'\n",
 		me->value));
-	if (!(me->value && *me->value))
+	if (me->value[0] == '\0')
 	    break;
 	/*
 	 * Check whether to set no_cache for the anchor.  - FM
@@ -963,7 +963,7 @@ static int dispatchField(HTStream *me)
 	HTMIME_TrimDoubleQuotes(me->value);
 	CTRACE((tfp, "HTMIME: PICKED UP Safe: '%s'\n",
 		me->value));
-	if (!(me->value && *me->value))
+	if (me->value[0] == '\0')
 	    break;
 	/*
 	 * Indicate in anchor if "YES" or "TRUE".  - FM
@@ -984,7 +984,7 @@ static int dispatchField(HTStream *me)
 	HTMIME_TrimDoubleQuotes(me->value);
 	CTRACE((tfp, "HTMIME: PICKED UP Server: '%s'\n",
 		me->value));
-	if (!(me->value && *me->value))
+	if (me->value[0] == '\0')
 	    break;
 	/*
 	 * Indicate in anchor.  - FM
@@ -2332,6 +2332,7 @@ static void HTmmdec_base64(char **t,
 
 	for (j = 0; j <= count; j++) {
 	    if (!(p = strchr(HTmm64, s[j]))) {
+		FREE(buf);
 		return;
 	    }
 	    d = (int) (p - HTmm64);
diff --git a/WWW/Library/Implementation/HTRules.c b/WWW/Library/Implementation/HTRules.c
index 35b36719..941d19af 100644
--- a/WWW/Library/Implementation/HTRules.c
+++ b/WWW/Library/Implementation/HTRules.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTRules.c,v 1.42 2010/06/17 21:33:35 tom Exp $
+ * $LynxId: HTRules.c,v 1.43 2013/05/01 00:45:32 tom Exp $
  *
  *	Configuration manager for Hypertext Daemon		HTRules.c
  *	==========================================
@@ -453,7 +453,7 @@ int HTSetConfiguration(char *config)
 {
     HTRuleOp op;
     char *line = NULL;
-    char *pointer = line;
+    char *pointer = NULL;
     char *word1;
     const char *word2;
     const char *word3;
diff --git a/WWW/Library/Implementation/HTTP.c b/WWW/Library/Implementation/HTTP.c
index 0a8f7411..1539a8b8 100644
--- a/WWW/Library/Implementation/HTTP.c
+++ b/WWW/Library/Implementation/HTTP.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTTP.c,v 1.126 2012/11/13 22:49:46 tom Exp $
+ * $LynxId: HTTP.c,v 1.127 2013/01/04 09:42:02 tom Exp $
  *
  * HyperText Tranfer Protocol	- Client implementation		HTTP.c
  * ==========================
@@ -194,10 +194,8 @@ void HTSSLInitPRNG(void)
 
 	RAND_file_name(rand_file, 256L);
 	CTRACE((tfp, "HTTP: Seeding PRNG\n"));
-	if (rand_file != NULL) {
-	    /* Seed as much as 1024 bytes from RAND_file_name */
-	    RAND_load_file(rand_file, 1024L);
-	}
+	/* Seed as much as 1024 bytes from RAND_file_name */
+	RAND_load_file(rand_file, 1024L);
 	/* Seed in time (mod_ssl does this) */
 	RAND_seed((unsigned char *) &t, (int) sizeof(time_t));
 
@@ -212,10 +210,8 @@ void HTSSLInitPRNG(void)
 	    l = lynx_rand();
 	    RAND_seed((unsigned char *) &l, (int) sizeof(long));
 	}
-	if (rand_file != NULL) {
-	    /* Write a rand_file */
-	    RAND_write_file(rand_file);
-	}
+	/* Write a rand_file */
+	RAND_write_file(rand_file);
     }
 #endif /* SSLEAY_VERSION_NUMBER >= 0x00905100 */
     return;
diff --git a/WWW/Library/Implementation/HTTelnet.c b/WWW/Library/Implementation/HTTelnet.c
index f525d5c7..4e01a912 100644
--- a/WWW/Library/Implementation/HTTelnet.c
+++ b/WWW/Library/Implementation/HTTelnet.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTTelnet.c,v 1.39 2009/11/21 17:05:33 Bela.Lubkin Exp $
+ * $LynxId: HTTelnet.c,v 1.40 2013/01/04 21:42:42 tom Exp $
  *
  *		Telnet Access, Rlogin, etc			HTTelnet.c
  *		==========================
@@ -101,7 +101,7 @@ static int remote_session(char *acc_method, char *host)
     if (port)
 	*port++ = '\0';		/* Split */
 
-    if (!hostname || *hostname == '\0') {
+    if (*hostname == '\0') {
 	CTRACE((tfp, "HTTelnet: No host specified!\n"));
 	return HT_NO_DATA;
     } else if (!valid_hostname(hostname)) {
diff --git a/WWW/Library/Implementation/HTUtils.h b/WWW/Library/Implementation/HTUtils.h
index 60106f72..a083df4a 100644
--- a/WWW/Library/Implementation/HTUtils.h
+++ b/WWW/Library/Implementation/HTUtils.h
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTUtils.h,v 1.112 2012/08/15 23:11:48 tom Exp $
+ * $LynxId: HTUtils.h,v 1.113 2013/04/30 22:45:03 tom Exp $
  *
  * Utility macros for the W3 code library
  * MACROS FOR GENERAL USE
@@ -55,8 +55,6 @@ char *alloca();
 #include <sys/types.h>
 #include <stdio.h>
 
-#define DONT_TRACK_INTERNAL_LINKS 1
-
 /* Explicit system-configure */
 #ifdef VMS
 #define NO_SIZECHANGE