about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2018-05-16 23:26:54 +0000
committerThomas E. Dickey <dickey@invisible-island.net>2018-05-16 23:26:54 +0000
commit47026439e28cec53560b90f6d3e7e32c6b65c0e0 (patch)
treedbbf7018a2f0f9515199bdac099bb4a70ef86f5d /src
parent95c887eee01b9e2a376e18ed178e32c2bccf3ff5 (diff)
downloadlynx-snapshots-47026439e28cec53560b90f6d3e7e32c6b65c0e0.tar.gz
snapshot of project "lynx", label v2-8-9dev_18d
Diffstat (limited to 'src')
-rw-r--r--src/GridText.c4
-rw-r--r--src/LYUtils.c31
2 files changed, 26 insertions, 9 deletions
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