diff options
author | Tatsuya Kinoshita <tats@debian.org> | 2021-04-23 11:16:50 +0000 |
---|---|---|
committer | Tatsuya Kinoshita <tats@debian.org> | 2021-04-23 11:16:50 +0000 |
commit | 59ea885da07c0916fb5917efb5538df2ecec1553 (patch) | |
tree | 7788717c19054ae6300f222374c1179e00bf9c8d /main.c | |
parent | Update ChangeLog (diff) | |
download | w3m-59ea885da07c0916fb5917efb5538df2ecec1553.tar.gz w3m-59ea885da07c0916fb5917efb5538df2ecec1553.zip |
Treat 127.0.0.1, [::1], and hostname as localhost
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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] == '-') { |