about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--CHANGES6
-rw-r--r--PACKAGE/debian/control2
-rw-r--r--WWW/Library/Implementation/HTFTP.c131
-rw-r--r--WWW/Library/Implementation/HTGopher.c5
-rw-r--r--WWW/Library/Implementation/HTTCP.c25
-rw-r--r--WWW/Library/Implementation/HTTCP.h9
-rw-r--r--WWW/Library/Implementation/HTUtils.h6
-rw-r--r--WWW/Library/Implementation/SGML.c6
-rw-r--r--WWW/Library/Implementation/www_tcp.h24
-rw-r--r--lynx.man49
-rw-r--r--src/GridText.c4
-rw-r--r--src/LYUtils.c31
-rw-r--r--userdefs.h6
13 files changed, 158 insertions, 146 deletions
diff --git a/CHANGES b/CHANGES
index 94cef39e..901471eb 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,9 +1,11 @@
--- $LynxId: CHANGES,v 1.980 2018/05/12 00:19:30 tom Exp $
+-- $LynxId: CHANGES,v 1.981 2018/05/16 23:26:54 tom Exp $
 ===============================================================================
 Changes since Lynx 2.8 release
 ===============================================================================
 
-2018-05-11 (2.8.9dev.19)
+2018-05-16 (2.8.9dev.19)
+* improve portability for sockaddr structures used in HTTP and FTP, for
+  IPv6 and SOCKS configurations -TD
 * fix several minor warnings reported by Coverity -TD
 * build-fix overlooked in 2.8.9dev.3 when INACTIVE_INPUT_STYLE_VH is defined,
   for problem introduced by 2.8.8dev.17 code-cleanup -GV
diff --git a/PACKAGE/debian/control b/PACKAGE/debian/control
index 653b9750..b0dd38b2 100644
--- a/PACKAGE/debian/control
+++ b/PACKAGE/debian/control
@@ -1,6 +1,6 @@
 Source: lynx-dev
 Section: web
-Priority: extra
+Priority: optional
 Maintainer: Thomas E. Dickey <dickey@invisible-island.net>
 Homepage: http://invisible-island.net/lynx/
 Build-Depends: debhelper (>= 7), dpatch, po-debconf, libncursesw5-dev, zlib1g-dev, gettext, libgnutls-dev, sharutils, telnet, openssh-client, libbsd-dev, libidn11-dev
diff --git a/WWW/Library/Implementation/HTFTP.c b/WWW/Library/Implementation/HTFTP.c
index 63c8d780..dbe278f6 100644
--- a/WWW/Library/Implementation/HTFTP.c
+++ b/WWW/Library/Implementation/HTFTP.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTFTP.c,v 1.132 2018/03/28 08:51:10 Gisle.Vanem Exp $
+ * $LynxId: HTFTP.c,v 1.137 2018/05/16 19:36:44 tom Exp $
  *
  *			File Transfer Protocol (FTP) Client
  *			for a WorldWideWeb browser
@@ -1156,15 +1156,11 @@ static int close_master_socket(void)
  */
 static int get_listen_socket(void)
 {
+    LY_SOCKADDR soc_A;
+
 #ifdef INET6
-    struct sockaddr_storage soc_address;	/* Binary network address */
-    struct sockaddr_in *soc_in = (struct sockaddr_in *) &soc_address;
-    int af;
+    unsigned short af;
     LY_SOCKLEN slen;
-
-#else
-    struct sockaddr_in soc_address;	/* Binary network address */
-    struct sockaddr_in *soc_in = &soc_address;
 #endif /* INET6 */
     int new_socket;		/* Will be master_socket */
 
@@ -1178,13 +1174,12 @@ static int get_listen_socket(void)
 
 #ifdef INET6
     /* query address family of control connection */
-    slen = (LY_SOCKLEN) sizeof(soc_address);
-    if (getsockname(control->socket, (struct sockaddr *) &soc_address,
-		    &slen) < 0) {
+    slen = (LY_SOCKLEN) sizeof(soc_A);
+    if (getsockname(control->socket, SOCKADDR_OF(soc_A), &slen) < 0) {
 	return HTInetStatus("getsockname failed");
     }
-    af = ((struct sockaddr *) &soc_address)->sa_family;
-    memset(&soc_address, 0, sizeof(soc_address));
+    af = SOCKADDR_OF(soc_A)->sa_family;
+    memset(&soc_A, 0, sizeof(soc_A));
 #endif /* INET6 */
 
 /*  Create internet socket
@@ -1203,25 +1198,25 @@ static int get_listen_socket(void)
 /*  Search for a free port.
 */
 #ifdef INET6
-    memset(&soc_address, 0, sizeof(soc_address));
-    ((struct sockaddr *) &soc_address)->sa_family = af;
+    memset(&soc_A, 0, sizeof(soc_A));
+    SOCKADDR_OF(soc_A)->sa_family = (unsigned short) af;
     switch (af) {
     case AF_INET:
 #ifdef SIN6_LEN
-	((struct sockaddr *) &soc_address)->sa_len = sizeof(struct sockaddr_in);
+	SOCKADDR_OF(soc_A)->sa_len = sizeof(struct sockaddr_in);
 #endif /* SIN6_LEN */
 	break;
     case AF_INET6:
 #ifdef SIN6_LEN
-	((struct sockaddr *) &soc_address)->sa_len = sizeof(struct sockaddr_in6);
+	SOCKADDR_OF(soc_A)->sa_len = sizeof(struct sockaddr_in6);
 #endif /* SIN6_LEN */
 	break;
     default:
 	HTInetStatus("AF");
     }
 #else
-    soc_in->sin_family = AF_INET;	/* Family = internet, host order  */
-    soc_in->sin_addr.s_addr = INADDR_ANY;	/* Any peer address */
+    soc_A.soc_in.sin_family = AF_INET;	/* Family = internet, host order  */
+    soc_A.soc_in.sin_addr.s_addr = INADDR_ANY;	/* Any peer address */
 #endif /* INET6 */
 #ifdef POLL_PORTS
     {
@@ -1236,23 +1231,21 @@ static int get_listen_socket(void)
 		return HTInetStatus("bind");
 	    }
 #ifdef INET6
-	    soc_in->sin_port = htons(port_number);
+	    soc_A.soc_in.sin_port = htons(port_number);
 #else
-	    soc_address.sin_port = htons(port_number);
+	    soc_A.sin_port = htons(port_number);
 #endif /* INET6 */
 #ifdef SOCKS
 	    if (socks_flag)
 		if ((status = Rbind(new_socket,
-				    (struct sockaddr *) &soc_address,
-		/* Cast to generic sockaddr */
-				    SOCKADDR_LEN(soc_address))) == 0) {
+				    SOCKADDR_OF(soc_A),
+				    SOCKADDR_LEN(soc_A))) == 0) {
 		    break;
 		} else
 #endif /* SOCKS */
 		    if ((status = bind(new_socket,
-				       (struct sockaddr *) &soc_address,
-		    /* Cast to generic sockaddr */
-				       SOCKADDR_LEN(soc_address)
+				       SOCKADDR_OF(soc_A),
+				       SOCKADDR_LEN(soc_A)
 			 )) == 0) {
 		    break;
 		}
@@ -1263,61 +1256,51 @@ static int get_listen_socket(void)
 #else
     {
 	int status;
-	LY_SOCKLEN address_length = (LY_SOCKLEN) sizeof(soc_address);
+	LY_SOCKLEN address_length = (LY_SOCKLEN) sizeof(soc_A);
 
 #ifdef SOCKS
 	if (socks_flag)
 	    status = Rgetsockname(control->socket,
-				  (struct sockaddr *) &soc_address,
+				  SOCKADDR_OF(soc_A),
 				  &address_length);
 	else
 #endif /* SOCKS */
 	    status = getsockname(control->socket,
-				 (struct sockaddr *) &soc_address,
+				 SOCKADDR_OF(soc_A),
 				 &address_length);
 	if (status < 0) {
 	    close(new_socket);
 	    return HTInetStatus("getsockname");
 	}
-#ifdef INET6
 	CTRACE((tfp, "HTFTP: This host is %s\n",
-		HTInetString((void *) soc_in)));
+		HTInetString((void *) &soc_A.soc_in)));
 
-	soc_in->sin_port = 0;	/* Unspecified: please allocate */
-#else
-	CTRACE((tfp, "HTFTP: This host is %s\n",
-		HTInetString(soc_in)));
-
-	soc_address.sin_port = 0;	/* Unspecified: please allocate */
-#endif /* INET6 */
+	soc_A.soc_in.sin_port = 0;	/* Unspecified: please allocate */
 #ifdef SOCKS
 	if (socks_flag)
 	    status = Rbind(new_socket,
-			   (struct sockaddr *) &soc_address,
-	    /* Cast to generic sockaddr */
-			   sizeof(soc_address));
+			   SOCKADDR_OF(soc_A),
+			   sizeof(soc_A));
 	else
 #endif /* SOCKS */
 	    status = bind(new_socket,
-			  (struct sockaddr *) &soc_address,
-	    /* Cast to generic sockaddr */
-			  SOCKADDR_LEN(soc_address)
-		);
+			  SOCKADDR_OF(soc_A),
+			  SOCKADDR_LEN(soc_A));
 	if (status < 0) {
 	    close(new_socket);
 	    return HTInetStatus("bind");
 	}
 
-	address_length = sizeof(soc_address);
+	address_length = sizeof(soc_A);
 #ifdef SOCKS
 	if (socks_flag)
 	    status = Rgetsockname(new_socket,
-				  (struct sockaddr *) &soc_address,
+				  SOCKADDR_OF(soc_A),
 				  &address_length);
 	else
 #endif /* SOCKS */
 	    status = getsockname(new_socket,
-				 (struct sockaddr *) &soc_address,
+				 SOCKADDR_OF(soc_A),
 				 &address_length);
 	if (status < 0) {
 	    close(new_socket);
@@ -1326,15 +1309,9 @@ static int get_listen_socket(void)
     }
 #endif /* POLL_PORTS */
 
-#ifdef INET6
-    CTRACE((tfp, "HTFTP: bound to port %d on %s\n",
-	    (int) ntohs(soc_in->sin_port),
-	    HTInetString((void *) soc_in)));
-#else
     CTRACE((tfp, "HTFTP: bound to port %d on %s\n",
-	    (int) ntohs(soc_in->sin_port),
-	    HTInetString(soc_in)));
-#endif /* INET6 */
+	    (int) ntohs(soc_A.soc_in.sin_port),
+	    HTInetString((void *) &soc_A.soc_in)));
 
 #ifdef REPEAT_LISTEN
     if (have_socket)
@@ -1347,16 +1324,16 @@ static int get_listen_socket(void)
 */
     (void) HTHostName();	/* Make address valid - doesn't work */
 #ifdef INET6
-    switch (((struct sockaddr *) &soc_address)->sa_family) {
+    switch (SOCKADDR_OF(soc_A)->sa_family) {
     case AF_INET:
 #endif /* INET6 */
 	sprintf(port_command, "PORT %d,%d,%d,%d,%d,%d%c%c",
-		(int) *((unsigned char *) (&soc_in->sin_addr) + 0),
-		(int) *((unsigned char *) (&soc_in->sin_addr) + 1),
-		(int) *((unsigned char *) (&soc_in->sin_addr) + 2),
-		(int) *((unsigned char *) (&soc_in->sin_addr) + 3),
-		(int) *((unsigned char *) (&soc_in->sin_port) + 0),
-		(int) *((unsigned char *) (&soc_in->sin_port) + 1),
+		(int) *((unsigned char *) (&soc_A.soc_in.sin_addr) + 0),
+		(int) *((unsigned char *) (&soc_A.soc_in.sin_addr) + 1),
+		(int) *((unsigned char *) (&soc_A.soc_in.sin_addr) + 2),
+		(int) *((unsigned char *) (&soc_A.soc_in.sin_addr) + 3),
+		(int) *((unsigned char *) (&soc_A.soc_in.sin_port) + 0),
+		(int) *((unsigned char *) (&soc_A.soc_in.sin_port) + 1),
 		CR, LF);
 
 #ifdef INET6
@@ -1367,8 +1344,8 @@ static int get_listen_socket(void)
 	    char hostbuf[MAXHOSTNAMELEN];
 	    char portbuf[MAXHOSTNAMELEN];
 
-	    getnameinfo((struct sockaddr *) &soc_address,
-			SOCKADDR_LEN(soc_address),
+	    getnameinfo(SOCKADDR_OF(soc_A),
+			SOCKADDR_LEN(soc_A),
 			hostbuf,
 			(socklen_t) sizeof(hostbuf),
 			portbuf,
@@ -1448,7 +1425,7 @@ static void set_years_and_date(void)
     sprintf(date, "9999%02d%.2s", i, day);
     TheDate = atoi(date);
     LYStrNCpy(ThisYear, printable + 20, 4);
-    sprintf(LastYear, "%d", (atoi(ThisYear) - 1));
+    sprintf(LastYear, "%d", (atoi(ThisYear) - 1) % 10000);
     HaveYears = TRUE;
 }
 
@@ -3359,7 +3336,7 @@ static int setup_connection(const char *name,
 		sprintf(dst, "%d.%d.%d.%d", h0, h1, h2, h3);
 	    } else if (strcmp(p, "EPSV") == 0) {
 		char c0, c1, c2, c3;
-		struct sockaddr_storage ss;
+		LY_SOCKADDR ss;
 		LY_SOCKLEN sslen;
 
 		/*
@@ -3382,13 +3359,12 @@ static int setup_connection(const char *name,
 		passive_port = (PortNumber) p0;
 
 		sslen = (LY_SOCKLEN) sizeof(ss);
-		if (getpeername(control->socket, (struct sockaddr *) &ss,
-				&sslen) < 0) {
+		if (getpeername(control->socket, SOCKADDR_OF(ss), &sslen) < 0) {
 		    fprintf(tfp, "HTFTP: getpeername(control) failed\n");
 		    status = HT_NO_CONNECTION;
 		    break;
 		}
-		if (getnameinfo((struct sockaddr *) &ss,
+		if (getnameinfo(SOCKADDR_OF(ss),
 				sslen,
 				dst,
 				(socklen_t) sizeof(dst),
@@ -4015,23 +3991,18 @@ int HTFTPLoad(const char *name,
   listen:
     if (!ftp_local_passive) {
 	/* Wait for the connection */
-#ifdef INET6
-	struct sockaddr_storage soc_address;
-
-#else
-	struct sockaddr_in soc_address;
-#endif /* INET6 */
-	LY_SOCKLEN soc_addrlen = (LY_SOCKLEN) sizeof(soc_address);
+	LY_SOCKADDR soc_A;
+	LY_SOCKLEN soc_addrlen = (LY_SOCKLEN) sizeof(soc_A);
 
 #ifdef SOCKS
 	if (socks_flag)
 	    status = Raccept((int) master_socket,
-			     (struct sockaddr *) &soc_address,
+			     SOCKADDR_OF(soc_A),
 			     &soc_addrlen);
 	else
 #endif /* SOCKS */
 	    status = accept((int) master_socket,
-			    (struct sockaddr *) &soc_address,
+			    SOCKADDR_OF(soc_A),
 			    &soc_addrlen);
 	if (status < 0) {
 	    init_help_message_cache();	/* to free memory */
diff --git a/WWW/Library/Implementation/HTGopher.c b/WWW/Library/Implementation/HTGopher.c
index 1417d9b6..a9ad41e4 100644
--- a/WWW/Library/Implementation/HTGopher.c
+++ b/WWW/Library/Implementation/HTGopher.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTGopher.c,v 1.67 2018/05/04 22:42:37 tom Exp $
+ * $LynxId: HTGopher.c,v 1.68 2018/05/15 21:58:15 tom Exp $
  *
  *			GOPHER ACCESS				HTGopher.c
  *			=============
@@ -970,7 +970,6 @@ static int parse_cso_fields(char *buf,
 	     * Lines beginning with 5 are errors.  Print them and quit.
 	     */
 	    if (*p == '5') {
-		strcpy(buf, p);
 		return 5;
 	    }
 
@@ -1712,7 +1711,7 @@ static char *link_to_URL(const char *arg)
 	result = next + 1;
     }
     /* check if the selector is the special html one */
-    if (!strncmp(result, "hURL:", (size_t)5)) {
+    if (!strncmp(result, "hURL:", (size_t) 5)) {
 	result += 5;
 	next = result;
 	result = temp;
diff --git a/WWW/Library/Implementation/HTTCP.c b/WWW/Library/Implementation/HTTCP.c
index ce014ce9..4669efd4 100644
--- a/WWW/Library/Implementation/HTTCP.c
+++ b/WWW/Library/Implementation/HTTCP.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTTCP.c,v 1.144 2018/03/30 00:13:21 tom Exp $
+ * $LynxId: HTTCP.c,v 1.149 2018/05/16 19:48:49 tom Exp $
  *
  *			Generic Communication Code		HTTCP.c
  *			==========================
@@ -280,18 +280,20 @@ unsigned int HTCardinal(int *pstatus,
  *	returns a pointer to a static string which must be copied if
  *		it is to be kept.
  */
-const char *HTInetString(SockA * soc_in)
+const char *HTInetString(LY_SOCKADDR * soc_A)
 {
 #ifdef INET6
     static char hostbuf[MAXHOSTNAMELEN];
+    struct sockaddr *soc_addr = &(soc_A->soc_address);
 
-    getnameinfo((struct sockaddr *) soc_in,
-		SOCKADDR_LEN(soc_in),
+    getnameinfo(soc_addr,
+		SA_LEN(soc_addr),
 		hostbuf, (socklen_t) sizeof(hostbuf),
 		NULL, 0,
 		NI_NUMERICHOST);
     return hostbuf;
 #else
+    struct sockaddr_in *soc_in = &(soc_A->soc_in);
     static char string[20];
 
     sprintf(string, "%d.%d.%d.%d",
@@ -1832,8 +1834,8 @@ int HTDoConnect(const char *url,
     LYNX_ADDRINFO *res = 0, *res0 = 0;
 
 #else
-    struct sockaddr_in soc_address;
-    struct sockaddr_in *soc_in = &soc_address;
+    struct sockaddr_in sock_A;
+    struct sockaddr_in *soc_in = &sock_A;
 
     /*
      * Set up defaults.
@@ -1950,15 +1952,14 @@ int HTDoConnect(const char *url,
 #ifdef INET6
 	    status = Rconnect(*s, res->ai_addr, res->ai_addrlen);
 #else
-	    status = Rconnect(*s, (struct sockaddr *) &soc_address,
-			      sizeof(soc_address));
+	    status = Rconnect(*s, SOCKADDR_OF(sock_A), sizeof(sock_A));
 #endif /* INET6 */
 	} else
 #endif /* SOCKS */
 #ifdef INET6
 	    status = connect(*s, res->ai_addr, res->ai_addrlen);
 #else
-	    status = connect(*s, (struct sockaddr *) &soc_address, sizeof(soc_address));
+	    status = connect(*s, SOCKADDR_OF(sock_A), sizeof(sock_A));
 #endif /* INET6 */
 
 	/*
@@ -2079,8 +2080,7 @@ int HTDoConnect(const char *url,
 #ifdef INET6
 			status = connect(*s, res->ai_addr, res->ai_addrlen);
 #else
-			status = connect(*s, (struct sockaddr *) &soc_address,
-					 sizeof(soc_address));
+			status = connect(*s, SOCKADDR_OF(sock_A), sizeof(sock_A));
 #endif /* INET6 */
 #ifdef UCX
 			/*
@@ -2132,8 +2132,7 @@ int HTDoConnect(const char *url,
 #ifdef INET6
 		    status = connect(*s, res->ai_addr, res->ai_addrlen);
 #else
-		    status = connect(*s, (struct sockaddr *) &soc_address,
-				     sizeof(soc_address));
+		    status = connect(*s, SOCKADDR_OF(sock_A), sizeof(sock_A));
 #endif /* INET6 */
 		    if ((status < 0) &&
 			(SOCKET_ERRNO != EALREADY
diff --git a/WWW/Library/Implementation/HTTCP.h b/WWW/Library/Implementation/HTTCP.h
index 878053ce..a15b2903 100644
--- a/WWW/Library/Implementation/HTTCP.h
+++ b/WWW/Library/Implementation/HTTCP.h
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTTCP.h,v 1.25 2018/03/28 21:14:18 tom Exp $
+ * $LynxId: HTTCP.h,v 1.27 2018/05/16 19:48:16 tom Exp $
  *
  *                               /Net/dxcern/userd/timbl/hypertext/WWW/Library/src/HTTCP.html
  *                             GENERIC TCP/IP COMMUNICATION
@@ -23,12 +23,7 @@ extern "C" {
  *           returns a pointer to a static string which must be copied if
  *                it is to be kept.
  */
-#ifdef INET6
-    extern const char *HTInetString(SockA * mysin);
-
-#else
-    extern const char *HTInetString(struct sockaddr_in *mysin);
-#endif				/* INET6 */
+    extern const char *HTInetString(LY_SOCKADDR * mysin);
 
 /*      Encode INET status (as in sys/errno.h)                    inet_status()
  *      ------------------
diff --git a/WWW/Library/Implementation/HTUtils.h b/WWW/Library/Implementation/HTUtils.h
index 571cc17f..cffa3b6e 100644
--- a/WWW/Library/Implementation/HTUtils.h
+++ b/WWW/Library/Implementation/HTUtils.h
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTUtils.h,v 1.128 2018/03/17 15:56:11 tom Exp $
+ * $LynxId: HTUtils.h,v 1.129 2018/05/16 22:16:05 tom Exp $
  *
  * Utility macros for the W3 code library
  * MACROS FOR GENERAL USE
@@ -706,7 +706,7 @@ extern int WWW_TraceMask;
  * definitions have to be included everywhere, since they're making wrappers
  * for the stdio functions as well as the network functions.
  */
-#if defined(USE_SOCKS5) && !defined(DONT_USE_SOCKS5)
+#if defined(USE_SOCKS5)
 #define SOCKS4TO5		/* turn on the Rxxxx definitions used in Lynx */
 #include <socks.h>
 
@@ -744,6 +744,8 @@ extern int WWW_TraceMask;
 #define Rselect       select
 #endif
 
+#elif defined(SOCKS)
+#include <socks.h>
 #endif /* USE_SOCKS5 */
 
 #ifdef USE_SSL
diff --git a/WWW/Library/Implementation/SGML.c b/WWW/Library/Implementation/SGML.c
index fab1ad95..193e68dd 100644
--- a/WWW/Library/Implementation/SGML.c
+++ b/WWW/Library/Implementation/SGML.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: SGML.c,v 1.162 2018/05/11 23:46:28 tom Exp $
+ * $LynxId: SGML.c,v 1.163 2018/05/15 21:55:21 tom Exp $
  *
  *			General SGML Parser code		SGML.c
  *			========================
@@ -53,8 +53,8 @@ static char *entity_string;	/* this is used for printing entity name.
 
 				   Unconditionally added since redundant assigments don't hurt much */
 
-static void fake_put_character(void *p GCC_UNUSED,
-			       char c GCC_UNUSED)
+static void fake_put_character(HTStream *p GCC_UNUSED,
+			       int c GCC_UNUSED)
 {
 }
 
diff --git a/WWW/Library/Implementation/www_tcp.h b/WWW/Library/Implementation/www_tcp.h
index 29b47adf..8a081a5a 100644
--- a/WWW/Library/Implementation/www_tcp.h
+++ b/WWW/Library/Implementation/www_tcp.h
@@ -1,5 +1,5 @@
 /*                System dependencies in the W3 library
- * $LynxId: www_tcp.h,v 1.54 2013/07/20 14:08:29 tom Exp $
+ * $LynxId: www_tcp.h,v 1.59 2018/05/16 20:31:43 tom Exp $
  *
                                    SYSTEM DEPENDENCIES
 
@@ -970,12 +970,19 @@ typedef TYPE_FD_SET fd_set;
 #endif
 #endif /* HAVE_GETADDRINFO && ENABLE_IPV6 */
 
+typedef union {
+    struct sockaddr_in soc_in;
+    struct sockaddr soc_address;
+#ifdef INET6
+    struct sockaddr_storage soc_storage;
+#endif
+} LY_SOCKADDR;
+
 #ifdef INET6
 typedef struct sockaddr_storage SockA;
 
-#ifdef SIN6_LEN
-#define SOCKADDR_LEN(soc_address) (((struct sockaddr *)&soc_address)->sa_len)
-#else
+#define SOCKADDR_OF(param) (&((param).soc_address))
+
 #ifndef SA_LEN
 #define SA_LEN(x) (((x)->sa_family == AF_INET6) \
 		   ? sizeof(struct sockaddr_in6) \
@@ -983,12 +990,17 @@ typedef struct sockaddr_storage SockA;
 		      ? sizeof(struct sockaddr_in) \
 		      : sizeof(struct sockaddr)))	/* AF_UNSPEC? */
 #endif
-#define SOCKADDR_LEN(soc_address) (socklen_t) (SA_LEN((struct sockaddr *)&soc_address))
+
+#ifdef SIN6_LEN
+#define SOCKADDR_LEN(param) (SOCKADDR_OF(param)->sa_len)
+#else
+#define SOCKADDR_LEN(param) (socklen_t) SA_LEN(SOCKADDR_OF(param))
 #endif /* SIN6_LEN */
 #else
 typedef struct sockaddr_in SockA;
 
-#define SOCKADDR_LEN(soc_address) sizeof(soc_address)
+#define SOCKADDR_OF(param) ((struct sockaddr *)&(param))
+#define SOCKADDR_LEN(param) sizeof(param)
 #endif /* INET6 */
 
 #ifndef MAXHOSTNAMELEN
diff --git a/lynx.man b/lynx.man
index 7aec7e2d..c3a4d072 100644
--- a/lynx.man
+++ b/lynx.man
@@ -1,4 +1,4 @@
-.\" $LynxId: lynx.man,v 1.120 2018/02/05 09:58:06 tom Exp $
+.\" $LynxId: lynx.man,v 1.121 2018/05/14 00:21:39 tom Exp $
 .\" **************************************************************************
 .\" Escape single quotes in literal strings from groff's Unicode transform.
 .ie \n(.g .ds AQ \(aq
@@ -86,7 +86,8 @@ Then follow the link titled, \*(``Help on URLs.\*(''
 .PP
 If more than one local file or remote URL is listed on the command line,
 \fILynx\fP will open only the last interactively.
-All of the names (local files and remote URLs) are added to the \fBG)oto\fP history.
+All of the names (local files and remote URLs)
+are added to the \fBG)oto\fP history.
 .PP
 \fILynx\fR uses only long option names.
 Option names can begin with double dash \*(``\-\-\*('' as well,
@@ -147,7 +148,8 @@ charset for documents that do not specify it.
 .TP
 .B \-assume_local_charset\fR=\fIMIMEname
 charset assumed for local files,
-i.e., files which \fILynx\fP creates such as internal pages for the options menu.
+i.e., files which \fILynx\fP creates such as
+internal pages for the options menu.
 .TP
 .B \-assume_unrec_charset\fR=\fIMIMEname
 use this instead of unrecognized charsets.
@@ -213,7 +215,8 @@ read keystroke commands from the specified file.
 You can use the data written using the \fB\-cmd_log\fR option.
 \fILynx\fP will ignore other information which the command-logging may have
 written to the logfile.
-Each line of the command script contains either a comment beginning with \*(``#\*('',
+Each line of the command script contains either
+a comment beginning with \*(``#\*('',
 or a keyword:
 .RS
 .TP 3
@@ -269,7 +272,8 @@ toggles handling of Set-Cookie headers.
 .TP
 .B \-core
 toggles forced core dumps on fatal errors.
-Turn this option off to ask \fILynx\fP to force a core dump if a fatal error occurs.
+Turn this option off to ask \fILynx\fP to force
+a core dump if a fatal error occurs.
 .TP
 .B \-crawl
 with \fB\-traversal,\fR output each page to a file.
@@ -719,8 +723,12 @@ domain (utmp required for selectivity).
 .B outside_news
 disallow USENET news reading and posting for people coming
 from outside your domain (utmp required for selectivity).
-This restriction applies to \*(``news\*('', \*(``nntp\*('', \*(``newspost\*('', and
-\*(``newsreply\*('' URLs, but not to \*(``snews\*('', \*(``snewspost\*('',
+This restriction applies to
+\*(``news\*('',
+\*(``nntp\*('',
+\*(``newspost\*('', and
+\*(``newsreply\*('' URLs,
+but not to \*(``snews\*('', \*(``snewspost\*('',
 or \*(``snewsreply\*('' in case they are supported.
 .TP
 .B outside_rlogin
@@ -779,7 +787,8 @@ portion which cannot be displayed.
 The beginning and end of the URL are displayed, rather than suppressing the end.
 .TP
 .B \-show_cfg
-Print the configuration settings, e.g., as read from \*(``lynx.cfg\*('', and exit.
+Print the configuration settings,
+e.g., as read from \*(``lynx.cfg\*('', and exit.
 .TP
 .B \-show_cursor
 If enabled the cursor will not be hidden in the right hand
@@ -878,7 +887,12 @@ color-style
 TRST (table layout)
 .TP
 .B 8
-configuration (lynx.cfg, \&.lynxrc, \&.lynx-keymaps, mime.types and mailcap contents)
+configuration
+(lynx.cfg,
+\&.lynxrc,
+\&.lynx-keymaps,
+mime.types and
+mailcap contents)
 .TP
 .B 16
 binary string copy/append, used in form data construction.
@@ -930,7 +944,8 @@ Click on the top line to scroll up.
 Click on the bottom line to scroll down.
 The first few positions in the top and bottom line may invoke
 additional functions.
-\fILynx\fP must be compiled with \fBncurses\fR or \fBslang\fR to support this feature.
+\fILynx\fP must be compiled with
+\fBncurses\fR or \fBslang\fR to support this feature.
 If \fBncurses\fR is used, clicking the middle mouse button pops up
 a simple menu.
 Mouse clicks may only work reliably while \fILynx\fP is
@@ -980,8 +995,8 @@ Use \fBUp arrow\fR and \fBDown arrow\fR to scroll through hypertext links.
 .bP
 \fBLeft Arrow\fR or \*(``\fBu\fR\*('' will retreat from a link.
 .bP
-Type \*(``\fBH\fR\*('', \*(``\fB?\fR\*('', or \fBF1\fR for online help and descriptions
-of key-stroke commands.
+Type \*(``\fBH\fR\*('', \*(``\fB?\fR\*('', or \fBF1\fR
+for online help and descriptions of key-stroke commands.
 .bP
 Type \*(``\fBk\fR\*('' or \*(``\fBK\fR\*('' for a list of the current key-stroke
 command mappings.
@@ -1204,8 +1219,8 @@ Note: If set/modified by \fILynx\fR, the values of the \fBLINES\fR and/or
 If built with the \fBcgi-links\fR option enabled, \fILynx\fR allows access
 to a cgi script directly without the need for an http daemon.
 .PP
-When executing such \*(``lynxcgi scripts\*('' (if enabled), the following variables
-may be set for simulating a CGI environment:
+When executing such \*(``lynxcgi scripts\*('' (if enabled),
+the following variables may be set for simulating a CGI environment:
 .PP
 .B CONTENT_LENGTH
 .PP
@@ -1335,9 +1350,9 @@ Also a special thanks to Foteos Macrides who ported
 much of \fILynx\fP to VMS and did or organized most of its development since the
 departures of Lou Montulli and Garrett Blythe from the University of Kansas
 in the summer of 1994 through the release of v2.7.2, and to everyone
-on the net who has contributed to \fILynx\fP's development either directly (through
-patches, comments or bug reports) or indirectly (through inspiration and
-development of other systems).
+on the net who has contributed to \fILynx\fP's development either directly
+(through patches, comments or bug reports) or indirectly
+(through inspiration and development of other systems).
 .SH AUTHORS
 Lou Montulli, Garrett Blythe, Craig Lavender, Michael Grobe, Charles Rezac
 .br
diff --git a/src/GridText.c b/src/GridText.c
index 784574b2..e7221bfa 100644
--- a/src/GridText.c
+++ b/src/GridText.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: GridText.c,v 1.312 2018/05/04 22:53:37 tom Exp $
+ * $LynxId: GridText.c,v 1.313 2018/05/15 20:43:41 tom Exp $
  *
  *		Character grid hypertext object
  *		===============================
@@ -1654,7 +1654,7 @@ static int display_line(HTLine *line,
 static void display_title(HText *text)
 {
     char *title = NULL;
-    char percent[20];
+    char percent[40];
     unsigned char *tmp = NULL;
     int i = 0, j = 0;
     int limit;
diff --git a/src/LYUtils.c b/src/LYUtils.c
index d123e916..682cbf2f 100644
--- a/src/LYUtils.c
+++ b/src/LYUtils.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYUtils.c,v 1.291 2018/03/28 21:14:39 tom Exp $
+ * $LynxId: LYUtils.c,v 1.292 2018/05/15 21:20:52 tom Exp $
  */
 #include <HTUtils.h>
 #include <HTTCP.h>
@@ -2937,21 +2937,38 @@ BOOLEAN inlocaldomain(void)
     struct utmp me;
     char *cp, *mytty = NULL;
 
-    if ((cp = ttyname(0)))
-	mytty = LYLastPathSep(cp);
+    if ((cp = ttyname(0))) {
+	mytty = cp;
+	if (!strncmp(mytty, "/dev/", 5)) {
+	    mytty += 5;		/* pty's can be like "pts/0" in utmp */
+	} else {
+	    if ((mytty = LYLastPathSep(cp)) != 0)
+		++mytty;
+	}
+    }
 
     result = FALSE;
     if (mytty && (fp = fopen(UTMP_FILE, "r")) != NULL) {
-	mytty++;
+	size_t ulen = strlen(mytty);
+
+	if (ulen > sizeof(me.ut_line))
+	    ulen = sizeof(me.ut_line);
 	do {
 	    n = (int) fread((char *) &me, sizeof(struct utmp), (size_t) 1, fp);
-	} while (n > 0 && !STREQ(me.ut_line, mytty));
+
+	    if (n <= 0)
+		break;
+	} while (memcmp(me.ut_line, mytty, ulen));
 	(void) LYCloseInput(fp);
 
 	if (n > 0) {
-	    if (strlen(me.ut_host) > strlen(LYLocalDomain) &&
+	    for (ulen = 0; ulen < sizeof(me.ut_host); ++ulen) {
+		if (me.ut_host[ulen] == '\0')
+		    break;
+	    }
+	    if (ulen > strlen(LYLocalDomain) &&
 		STREQ(LYLocalDomain,
-		      me.ut_host + strlen(me.ut_host) - strlen(LYLocalDomain))) {
+		      me.ut_host + ulen - strlen(LYLocalDomain))) {
 		result = TRUE;
 	    }
 #ifdef LINUX
diff --git a/userdefs.h b/userdefs.h
index a53099d3..d9b716cb 100644
--- a/userdefs.h
+++ b/userdefs.h
@@ -1,5 +1,5 @@
 /*
- * $LynxId: userdefs.h,v 1.336 2018/05/07 23:37:31 tom Exp $
+ * $LynxId: userdefs.h,v 1.337 2018/05/15 21:12:20 tom Exp $
  *
  * Lynx - Hypertext navigation system
  *
@@ -616,7 +616,7 @@
  * name of the system on which Lynx is running) will all be passed as
  * local.  A different definition in lynx.cfg will override this one.
  */
-/* #define LYNX_HOST_NAME "www.cc.ukans.edu" */
+/* #define LYNX_HOST_NAME "localhost" */
 
 /*********************
  * LOCAL_DOMAIN is used for a tail match with the ut_host element of
@@ -627,7 +627,7 @@
  * if your system does not have utmp capabilities.  CHANGE THIS here
  * or in lynx.cfg.
  */
-#define LOCAL_DOMAIN "ukans.edu"
+#define LOCAL_DOMAIN "localdomain"
 
 /********************************
 * The DEFAULT_CACHE_SIZE specifies the number of WWW documents to be