about summary refs log tree commit diff stats
path: root/src/LYUtils.c
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/LYUtils.c
parent95c887eee01b9e2a376e18ed178e32c2bccf3ff5 (diff)
downloadlynx-snapshots-47026439e28cec53560b90f6d3e7e32c6b65c0e0.tar.gz
snapshot of project "lynx", label v2-8-9dev_18d
Diffstat (limited to 'src/LYUtils.c')
-rw-r--r--src/LYUtils.c31
1 files changed, 24 insertions, 7 deletions
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
s='oid'>aeb7005
648ca98 ^



a21afda ^




1767e4f ^
a21afda ^

a0be5e8 ^

39c93d2 ^

60b351b ^
f406bf5 ^



b60999c ^
8126d82 ^
















f406bf5 ^
8126d82 ^
b60999c ^

f406bf5 ^
77a0f68 ^


1418e1b ^
60b351b ^
1418e1b ^

661e3ec ^

305446a ^
6394e38 ^
aeb7005
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93