[w3m-dev 02637]

From: Fumitoshi UKAI  <ukai@debian.or.jp>
This commit is contained in:
Fumitoshi UKAI
2001-12-06 22:45:04 +00:00
parent d7637adfc0
commit 397f68e930
2 changed files with 20 additions and 15 deletions

View File

@@ -1,3 +1,11 @@
2001-12-07 Fumitoshi UKAI <ukai@debian.or.jp>
* [w3m-dev 02637]
* url.c (openSocket): hostname volatile -> const
* url.c (openSocket): add hname
* url.c (openSocket): copy hostname to hname to be modified safely
* url.c (otherinfo): revert previous change
2001-12-07 Hironori Sakamoto <hsaka@mth.biglobe.ne.jp> 2001-12-07 Hironori Sakamoto <hsaka@mth.biglobe.ne.jp>
* [w3m-dev 02635] dirlist * [w3m-dev 02635] dirlist

25
url.c
View File

@@ -1,4 +1,4 @@
/* $Id: url.c,v 1.20 2001/12/06 16:35:37 ukai Exp $ */ /* $Id: url.c,v 1.21 2001/12/06 22:45:06 ukai Exp $ */
#include "fm.h" #include "fm.h"
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
@@ -419,7 +419,7 @@ baseURL(Buffer *buf)
} }
int int
openSocket(char *volatile hostname, openSocket(char *const hostname,
char *remoteport_name, unsigned short remoteport_num) char *remoteport_name, unsigned short remoteport_num)
{ {
volatile int sock = -1; volatile int sock = -1;
@@ -427,6 +427,7 @@ openSocket(char *volatile hostname,
int *af; int *af;
struct addrinfo hints, *res0, *res; struct addrinfo hints, *res0, *res;
int error; int error;
char *hname;
#else /* not INET6 */ #else /* not INET6 */
struct sockaddr_in hostaddr; struct sockaddr_in hostaddr;
struct hostent *entry; struct hostent *entry;
@@ -462,11 +463,12 @@ openSocket(char *volatile hostname,
#ifdef INET6 #ifdef INET6
/* rfc2732 compliance */ /* rfc2732 compliance */
if (hostname != NULL && hostname[0] == '[' && hname = hostname;
hostname[strlen(hostname) - 1] == ']') { if (hname != NULL && hname[0] == '[' &&
hostname[strlen(hostname) - 1] = '\0'; hname[strlen(hname) - 1] == ']') {
hostname++; hname = allocStr(hostname + 1, -1);
if (strspn(hostname, "0123456789abcdefABCDEF:.") != strlen(hostname)) hname[strlen(hname) - 1] = '\0';
if (strspn(hname, "0123456789abcdefABCDEF:.") != strlen(hname))
goto error; goto error;
} }
for (af = ai_family_order_table[DNS_order];; af++) { for (af = ai_family_order_table[DNS_order];; af++) {
@@ -475,14 +477,14 @@ openSocket(char *volatile hostname,
hints.ai_socktype = SOCK_STREAM; hints.ai_socktype = SOCK_STREAM;
if (remoteport_num != 0) { if (remoteport_num != 0) {
Str portbuf = Sprintf("%d", remoteport_num); Str portbuf = Sprintf("%d", remoteport_num);
error = getaddrinfo(hostname, portbuf->ptr, &hints, &res0); error = getaddrinfo(hname, portbuf->ptr, &hints, &res0);
} }
else { else {
error = -1; error = -1;
} }
if (error && remoteport_name && remoteport_name[0] != '\0') { if (error && remoteport_name && remoteport_name[0] != '\0') {
/* try default port */ /* try default port */
error = getaddrinfo(hostname, remoteport_name, &hints, &res0); error = getaddrinfo(hname, remoteport_name, &hints, &res0);
} }
if (error) { if (error) {
if (*af == PF_UNSPEC) { if (*af == PF_UNSPEC) {
@@ -1204,11 +1206,6 @@ otherinfo(ParsedURL *target, ParsedURL *current, char *referer)
if (target->host) { if (target->host) {
Strcat_charp(s, "Host: "); Strcat_charp(s, "Host: ");
#ifdef INET6
if (strchr(target->host, ':') != NULL)
Strcat(s, Sprintf("[%s]", target->host));
else
#endif
Strcat_charp(s, target->host); Strcat_charp(s, target->host);
if (target->port != DefaultPort[target->scheme]) if (target->port != DefaultPort[target->scheme])
Strcat(s, Sprintf(":%d", target->port)); Strcat(s, Sprintf(":%d", target->port));