aboutsummaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorTatsuya Kinoshita <tats@debian.org>2021-04-23 11:16:50 +0000
committerTatsuya Kinoshita <tats@debian.org>2021-04-23 11:16:50 +0000
commit59ea885da07c0916fb5917efb5538df2ecec1553 (patch)
tree7788717c19054ae6300f222374c1179e00bf9c8d /main.c
parentUpdate ChangeLog (diff)
downloadw3m-59ea885da07c0916fb5917efb5538df2ecec1553.tar.gz
w3m-59ea885da07c0916fb5917efb5538df2ecec1553.zip
Treat 127.0.0.1, [::1], and hostname as localhost
Diffstat (limited to '')
-rw-r--r--main.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/main.c b/main.c
index fa41cce..6f15e36 100644
--- a/main.c
+++ b/main.c
@@ -455,6 +455,18 @@ main(int argc, char **argv, char **envp)
BookmarkFile = NULL;
config_file = NULL;
+ {
+ char hostname[HOST_NAME_MAX + 2];
+ if (gethostname(hostname, HOST_NAME_MAX + 2) == 0) {
+ size_t hostname_len;
+ /* Don't use hostname if it is truncated. */
+ hostname[HOST_NAME_MAX + 1] = '\0';
+ hostname_len = strlen(hostname);
+ if (hostname_len <= HOST_NAME_MAX && hostname_len <= INT_MAX)
+ HostName = allocStr(hostname, (int)hostname_len);
+ }
+ }
+
/* argument search 1 */
for (i = 1; i < argc; i++) {
if (*argv[i] == '-') {