about summary refs log tree commit diff stats
path: root/WWW/Library/Implementation/HTTCP.c
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2020-01-22 02:02:15 +0000
committerThomas E. Dickey <dickey@invisible-island.net>2020-01-22 02:02:15 +0000
commit7fb4d1b4667658fdd1a92a2911be669c8aa78589 (patch)
tree87a4b9b6f06cc3a6b096859299506220b3378f40 /WWW/Library/Implementation/HTTCP.c
parent419cae0a458826eae34d29b3216f453957074d16 (diff)
downloadlynx-snapshots-7fb4d1b4667658fdd1a92a2911be669c8aa78589.tar.gz
snapshot of project "lynx", label v2-9-0dev_4i
Diffstat (limited to 'WWW/Library/Implementation/HTTCP.c')
-rw-r--r--WWW/Library/Implementation/HTTCP.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/WWW/Library/Implementation/HTTCP.c b/WWW/Library/Implementation/HTTCP.c
index c43ab7ac..2834c2c7 100644
--- a/WWW/Library/Implementation/HTTCP.c
+++ b/WWW/Library/Implementation/HTTCP.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTTCP.c,v 1.152 2019/09/19 00:27:19 Steffen.Nurpmeso Exp $
+ * $LynxId: HTTCP.c,v 1.155 2020/01/22 01:58:28 tom Exp $
  *
  *			Generic Communication Code		HTTCP.c
  *			==========================
@@ -1856,11 +1856,18 @@ int HTDoConnect(const char *url,
 	StrAllocCopy(socks5_new_url, url);
 
 	/* Get node name and optional port number of wanted URL */
-	p1 = HTParse(socks5_new_url, "", PARSE_HOST);
 	socks5_host = NULL;
-	StrAllocCopy(socks5_host, p1);
-	strip_userid(socks5_host, FALSE);
-	FREE(p1);
+	if ((p1 = HTParse(socks5_new_url, "", PARSE_HOST)) != NULL) {
+	    StrAllocCopy(socks5_host, p1);
+	    strip_userid(socks5_host, FALSE);
+	    FREE(p1);
+	}
+
+	if (isEmpty(socks5_host)) {
+	    emsg = gettext("SOCKS5: no hostname found.");
+	    status = HT_ERROR;
+	    goto report_error;
+	}
 
 	if (strlen(socks5_host) > 255) {
 	    emsg = gettext("SOCKS5: hostname too long.");
@@ -2286,7 +2293,7 @@ int HTDoConnect(const char *url,
 	/* C99 */  {
 	    unsigned short x;	/* XXX 16-bit? */
 
-	    x = htons(socks5_port);
+	    x = htons((unsigned) socks5_port);
 	    memcpy(&pbuf[i], (unsigned char *) &x, sizeof x);
 	    i += (unsigned) sizeof(x);
 	}