You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by wr...@apache.org on 2009/03/20 08:15:08 UTC

svn commit: r756355 - /httpd/sandbox/mod_remoteip/mod_remoteip.c

Author: wrowe
Date: Fri Mar 20 07:15:08 2009
New Revision: 756355

URL: http://svn.apache.org/viewvc?rev=756355&view=rev
Log:
byte access to in_addr (big endian net order)

Modified:
    httpd/sandbox/mod_remoteip/mod_remoteip.c

Modified: httpd/sandbox/mod_remoteip/mod_remoteip.c
URL: http://svn.apache.org/viewvc/httpd/sandbox/mod_remoteip/mod_remoteip.c?rev=756355&r1=756354&r2=756355&view=diff
==============================================================================
--- httpd/sandbox/mod_remoteip/mod_remoteip.c (original)
+++ httpd/sandbox/mod_remoteip/mod_remoteip.c Fri Mar 20 07:15:08 2009
@@ -146,11 +146,9 @@
 static const char *proxylist_read(cmd_parms *cmd, void *internal,
                                   const char *filename)
 {
-    remoteip_config_t *config = ap_get_module_config(cmd->server->module_config,
-                                                     &remoteip_module);
     char lbuf[MAX_STRING_LEN];
     char *arg;
-    char *args;
+    const char *args;
     const char *errmsg;
     ap_configfile_t *cfp;
     apr_status_t rv;
@@ -198,9 +196,10 @@
     char *proxy_ips = NULL;
     char *parse_remote;
     char *eos;
+    unsigned char *addrbyte;
     int internal = 0;
 
-    apr_pool_userdata_get(&conn, "mod_remoteip-conn", c->pool);
+    apr_pool_userdata_get((void*)&conn, "mod_remoteip-conn", c->pool);
 
     if (conn) {
         if (remote && (strcmp(remote, conn->prior_remote) == 0)) {
@@ -303,20 +302,18 @@
             break;
         }
 
+        addrbyte = (unsigned char *) &temp_sa->sa.sin.sin_addr;
         if (!internal
               && ((temp_sa->family == APR_INET
                          /* denying 127. loopback, 10., 172.240..., 192.168. 
                           * private subnets, and Class D and E special subnets
                           */
-                      && (temp_sa->sa.sin.sin_addr.s_net == 127
-                       || temp_sa->sa.sin.sin_addr.s_net == 10
-                       || (temp_sa->sa.sin.sin_addr.s_net == 172
-                        && temp_sa->sa.sin.sin_addr.s_host & 0xf0 == 0xf0)
-                       || (temp_sa->sa.sin.sin_addr.s_net == 192
-                        && temp_sa->sa.sin.sin_addr.s_host == 168)
-                       || (temp_sa->sa.sin.sin_addr.s_net == 169
-                        && temp_sa->sa.sin.sin_addr.s_host == 254)
-                       || temp_sa->sa.sin.sin_addr.s_net & 0xe0 == 0xe0))
+                      && (addrbyte[0] == 127
+                       || addrbyte[0] == 10
+                       || (addrbyte[0] == 172 && (addrbyte[1] & 0xf0) == 0xf0)
+                       || (addrbyte[0] == 192 && addrbyte[1] == 168)
+                       || (addrbyte[0] == 169 && addrbyte[1] == 254)
+                       || (addrbyte[0] & 0xe0) == 0xe0))
 #if APR_HAVE_IPV6
                || (temp_sa->family == APR_INET6
                          /* we translated IPv4-over-IPv6-mapped addresses 
@@ -324,8 +321,8 @@
                           * multicast, special subnets, etc etc, where the
                           * high nibble of the address is 0 or f
                           */
-                      && (temp_sa->sa.sin6.sin6_addr.s6_addr[0] & 0xf0 == 0x00
-                       || temp_sa->sa.sin6.sin6_addr.s6_addr[0] & 0xf0 == 0xf0))
+                      && ((temp_sa->sa.sin6.sin6_addr.s6_addr[0] & 0xf0) == 0x00
+                       || (temp_sa->sa.sin6.sin6_addr.s6_addr[0] & 0xf0) == 0xf0))
 #endif
         )) {
             ap_log_rerror(APLOG_MARK, APLOG_DEBUG,  rv, r,