summaryrefslogtreecommitdiff
path: root/www/wwwoffle/patches.v6/patch-ba
blob: c2e68ba56eabd11ce766c5f8edc2fac7ad0de6f3 (plain)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
$NetBSD: patch-ba,v 1.3 1999/11/26 06:09:01 itohy Exp $

--- config.c.orig	Thu Sep 23 01:31:33 1999
+++ config.c	Thu Nov 25 20:00:34 1999
@@ -798,11 +798,15 @@
     localhost=(*LocalHost)->key.string;
  else
     localhost="localhost";
-
+ 
  ret=(char*)malloc(strlen(localhost)+8);
 
- if(port)
-    sprintf(ret,"%s:%d",localhost,HTTP_Port);
+ if(port) {
+    if (strchr(localhost, ':')) 
+       sprintf(ret,"[%s]:%d",localhost,HTTP_Port);
+    else
+       sprintf(ret,"%s:%d",localhost,HTTP_Port);
+ }
  else
     strcpy(ret,localhost);
 
@@ -821,20 +825,32 @@
   int port If true then check the port number as well.
   ++++++++++++++++++++++++++++++++++++++*/
 
-int IsLocalHost(char *host,int port)
+int IsLocalHost(char *hoststr,int port)
 {
  KeyPair **p;
- char *colon=strchr(host,':');
+ char *escl, *escr, *host, *colon;
  int isit=0;
 
- if(colon)
-    *colon=0;
+ escl=strchr(hoststr,'[');
+ escr=strrchr(hoststr,']');
+ colon=strrchr(hoststr,':');
+ host = hoststr;
+
+ if (escl && escr) {
+     host = escl + 1;
+     *escr = 0;
+ }
+ else if(colon)
+     *colon=0;
 
  if(LocalHost)
     for(p=LocalHost;(*p)!=&KeyPairEnd;p++)
        if(!strcmp((*p)->key.string,host))
          {isit=1;break;}
 
+ if (escl && escr) 
+     *escr = ']';
+
  if(colon)
     *colon=':';
 
@@ -859,14 +875,23 @@
   char *host The name of the host (and port number) to be checked.
   ++++++++++++++++++++++++++++++++++++++*/
 
-int IsLocalNetHost(char *host)
+int IsLocalNetHost(char *hoststr)
 {
  KeyPair **p;
- char *colon=strchr(host,':');
+ char *escl, *escr, *host, *colon;
  int isit=0;
 
- if(colon)
-    *colon=0;
+ escl=strchr(hoststr,'[');
+ escr=strrchr(hoststr,']');
+ colon=strrchr(hoststr,':');
+ host = hoststr;
+
+ if (escl && escr) {
+     host = escl + 1;
+     *escr = 0;
+ }
+ else if(colon) 
+     *colon=0;
 
  if(IsLocalHost(host,0))
     isit=1;
@@ -881,6 +906,10 @@
        else if(wildcard_match(host,(*p)->key.string))
          {isit=1;break;}
 
+
+ if (escl && escr) 
+     *escr = ']';
+
  if(colon)
     *colon=':';
 
@@ -2192,7 +2221,7 @@
        {errmsg=(char*)malloc(40);strcpy(errmsg,"Expecting a hostname, got nothing.");}
      else
        {
-        char *colon=strchr(text,':'),*p;
+        char *colon = NULL,*p;
         if(colon)
           {errmsg=(char*)malloc(56+strlen(text));sprintf(errmsg,"Expecting a hostname not a port number, got '%s'.",text);}
         else
@@ -2219,7 +2248,7 @@
       {errmsg=(char*)malloc(48);strcpy(errmsg,"Expecting a hostname (and port), got nothing.");}
     else
       {
-       char *colon=strchr(text,':'),*p;
+       char *colon=strrchr(text,':'),*p;
        if(*text==':')
          {errmsg=(char*)malloc(48+strlen(text));sprintf(errmsg,"Expecting a hostname before the ':', got '%s'.",text);}
        else