You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Dean Gaudet <dg...@arctic.org> on 1997/03/06 13:05:49 UTC
[PATCH] PR#212: error trying to resolve 255.255.255.255
The "255.255.255.255" magic default address for virtualhost statements has
worked fine on my irix boxes ever since I wrote it... but apparently
hasn't been tested elsewhere. For some reason on my irix boxes if I do
gethostbyname("255.255.255.255") it returns something useful... but it
returns NULL on other machines here.
Since 255.255.255.255 is the same as the error value returned from
inet_addr and inet_network it's not possible to parse that value as input
(which is why some OSs have inet_aton which doesn't overload the return
value).
This could be solved by writing a portable inet_aton. Or it could be
worked around as in this patch I'm providing. I choose to just do a
string comparison against "255.255.255.255". I think rather than document
this magic number I'd like to use "_default_" as the magic key. So this
patch implements that. If it's accepted then we gotta update the docs...
I think the rest of the PR has been dealt with in the discussion between
James and Marc. (Except for the apache could have better diagnostic
messages remark, which I think is an open problem ;)
Dean
Index: httpd.h
===================================================================
RCS file: /export/home/cvs/apache/src/httpd.h,v
retrieving revision 1.90
diff -c -3 -r1.90 httpd.h
*** httpd.h 1997/02/22 00:47:32 1.90
--- httpd.h 1997/03/06 11:37:39
***************
*** 551,556 ****
--- 551,561 ----
/* Per-vhost config... */
+ /* The address 255.255.255.255, when used as a virtualhost address,
+ * will become the "default" server when the ip doesn't match other vhosts.
+ */
+ #define DEFAULT_VHOST_ADDR 0xfffffffful
+
typedef struct server_addr_rec server_addr_rec;
struct server_addr_rec {
server_addr_rec *next;
Index: http_main.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_main.c,v
retrieving revision 1.127
diff -c -3 -r1.127 http_main.c
*** http_main.c 1997/03/04 21:44:38 1.127
--- http_main.c 1997/03/06 11:37:40
***************
*** 176,186 ****
int one_process = 0;
- /* The address 255.255.255.255, when used as a virtualhost address,
- * will become the "default" server when the ip doesn't match other vhosts.
- */
- #define DEFAULT_VHOST_ADDR 0xfffffffful
-
#if defined(USE_FCNTL_SERIALIZED_ACCEPT)
static struct flock lock_it = { F_WRLCK, 0, 0, 0 };
static struct flock unlock_it = { F_UNLCK, 0, 0, 0 };
Index: http_config.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_config.c,v
retrieving revision 1.42
diff -c -3 -r1.42 http_config.c
*** http_config.c 1997/01/26 01:15:11 1.42
--- http_config.c 1997/03/06 11:37:40
***************
*** 865,887 ****
*t = 0;
}
if (strcmp(w, "*") == 0) {
! sar = pcalloc( p, sizeof( server_addr_rec ) );
! **paddr = sar;
! *paddr = &sar->next;
! sar->host_addr.s_addr = htonl(INADDR_ANY);
! sar->host_port = port;
! sar->virthost = pstrdup(p, w);
! if (t != NULL) *t = ':';
! return;
! }
!
#ifdef DGUX
! my_addr = inet_network(w);
#else
! my_addr = inet_addr(w);
#endif
! if (my_addr != INADDR_NONE) {
sar = pcalloc( p, sizeof( server_addr_rec ) );
**paddr = sar;
*paddr = &sar->next;
--- 871,894 ----
*t = 0;
}
+ i = 0;
if (strcmp(w, "*") == 0) {
! my_addr = htonl(INADDR_ANY);
! i = 1;
! } else if( strcmp(w, "_default_") == 0
! || strcmp(w, "255.255.255.255") == 0 ) {
! my_addr = DEFAULT_VHOST_ADDR;
! i = 1;
! } else if(
#ifdef DGUX
! ( my_addr = inet_network(w) )
#else
! ( my_addr = inet_addr(w) )
#endif
! != INADDR_NONE ) {
! i = 1;
! }
! if( i ) {
sar = pcalloc( p, sizeof( server_addr_rec ) );
**paddr = sar;
*paddr = &sar->next;