httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@locus.apache.org
Subject cvs commit: apache-2.0/src/modules/proxy mod_proxy.c mod_proxy.h proxy_connect.c proxy_ftp.c proxy_http.c proxy_util.c
Date Sun, 08 Oct 2000 03:23:07 GMT
rbb         00/10/07 20:23:06

  Modified:    src/modules/proxy mod_proxy.c mod_proxy.h proxy_connect.c
                        proxy_ftp.c proxy_http.c proxy_util.c
  Log:
  Remove all compiler warnings from the proxy code.  There are no garauntees
  that this still works, but most of the changes were just const-safeness
  changes.
  PR:	6631
  
  Revision  Changes    Path
  1.13      +48 -42    apache-2.0/src/modules/proxy/mod_proxy.c
  
  Index: mod_proxy.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/proxy/mod_proxy.c,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- mod_proxy.c	2000/08/06 06:07:43	1.12
  +++ mod_proxy.c	2000/10/08 03:23:05	1.13
  @@ -64,6 +64,7 @@
   #include "http_vhost.h"
   #include "http_request.h"
   #include "util_date.h"
  +#include "apr_strings.h"
   
   /* Some WWW schemes and their default ports; this is basically /etc/services */
   /* This will become global when the protocol abstraction comes */
  @@ -282,6 +283,7 @@
   static int proxy_handler(request_rec *r)
   {
       char *url, *scheme, *p;
  +    const char *p2;
       void *sconf = r->server->module_config;
       proxy_server_conf *conf = (proxy_server_conf *)
           ap_get_module_config(sconf, &proxy_module);
  @@ -404,10 +406,10 @@
   
       if (!direct_connect)
           for (i = 0; i < proxies->nelts; i++) {
  -            p = strchr(ents[i].scheme, ':');    /* is it a partial URL? */
  +            p2 = ap_strchr_c(ents[i].scheme, ':');  /* is it a partial URL? */
               if (strcmp(ents[i].scheme, "*") == 0 ||
  -                (p == NULL && strcasecmp(scheme, ents[i].scheme) == 0) ||
  -                (p != NULL &&
  +                (p2 == NULL && strcasecmp(scheme, ents[i].scheme) == 0) ||
  +                (p2 != NULL &&
                    strncasecmp(url, ents[i].scheme, strlen(ents[i].scheme)) == 0)) {
                   /* CONNECT is a special method that bypasses the normal
                    * proxy code.
  @@ -468,15 +470,18 @@
   }
   
   static const char *
  -     add_proxy(cmd_parms *cmd, void *dummy, char *f, char *r)
  +     add_proxy(cmd_parms *cmd, void *dummy, const char *f1, const char *r1)
   {
       server_rec *s = cmd->server;
       proxy_server_conf *conf =
       (proxy_server_conf *) ap_get_module_config(s->module_config, &proxy_module);
       struct proxy_remote *new;
       char *p, *q;
  +    char *r, *f;
       int port;
   
  +    r = apr_pstrdup(cmd->pool, r1);
  +    f = apr_pstrdup(cmd->pool, f1);
       p = strchr(r, ':');
       if (p == NULL || p[1] != '/' || p[2] != '/' || p[3] == '\0')
       return "ProxyRemote: Bad syntax for a remote proxy server";
  @@ -510,7 +515,7 @@
   }
   
   static const char *
  -     set_cache_exclude(cmd_parms *cmd, void *dummy, char *arg)
  +     set_cache_exclude(cmd_parms *cmd, void *dummy, const char *arg)
   {
       server_rec *s = cmd->server;
       proxy_server_conf *psf = (proxy_server_conf *) ap_get_module_config(s->module_config,
&proxy_module);
  @@ -530,8 +535,9 @@
           new = apr_push_array(psf->nocaches);
           new->name = arg;
           /* Don't do name lookups on things that aren't dotted */
  -        if (strchr(arg, '.') != NULL && ap_proxy_host2addr(new->name, &hp)
== NULL)
  -            /*@@@FIXME: This copies only the first of (possibly many) IP addrs */
  +        if (ap_strchr_c(arg, '.') != NULL && 
  +            ap_proxy_host2addr(new->name, &hp) == NULL)
  +           /*@@@FIXME: This copies only the first of (possibly many) IP addrs */
               memcpy(&new->addr, hp.h_addr, sizeof(struct in_addr));
           else
               new->addr.s_addr = 0;
  @@ -540,7 +546,7 @@
   }
   
   static const char *
  -     add_pass(cmd_parms *cmd, void *dummy, char *f, char *r)
  +     add_pass(cmd_parms *cmd, void *dummy, const char *f, const char *r)
   {
       server_rec *s = cmd->server;
       proxy_server_conf *conf =
  @@ -554,7 +560,7 @@
   }
   
   static const char *
  -    add_pass_reverse(cmd_parms *cmd, void *dummy, char *f, char *r)
  +    add_pass_reverse(cmd_parms *cmd, void *dummy, const char *f, const char *r)
   {
       server_rec *s = cmd->server;
       proxy_server_conf *conf;
  @@ -568,7 +574,7 @@
       return NULL;
   }
   
  -static const char *set_proxy_exclude(cmd_parms *parms, void *dummy, char *arg)
  +static const char *set_proxy_exclude(cmd_parms *parms, void *dummy, const char *arg)
   {
       server_rec *s = parms->server;
       proxy_server_conf *conf =
  @@ -589,7 +595,7 @@
       new = apr_push_array(conf->noproxies);
       new->name = arg;
       /* Don't do name lookups on things that aren't dotted */
  -    if (strchr(arg, '.') != NULL && ap_proxy_host2addr(new->name, &hp) ==
NULL)
  +    if (ap_strchr_c(arg, '.') != NULL && ap_proxy_host2addr(new->name, &hp)
== NULL)
           /*@@@FIXME: This copies only the first of (possibly many) IP addrs */
           memcpy(&new->addr, hp.h_addr, sizeof(struct in_addr));
       else
  @@ -602,7 +608,7 @@
    * Set the ports CONNECT can use
    */
   static const char *
  -    set_allowed_ports(cmd_parms *parms, void *dummy, char *arg)
  +    set_allowed_ports(cmd_parms *parms, void *dummy, const char *arg)
   {
       server_rec *s = parms->server;
       proxy_server_conf *conf =
  @@ -621,7 +627,7 @@
    * which should never be accessed via the configured ProxyRemote servers
    */
   static const char *
  -     set_proxy_dirconn(cmd_parms *parms, void *dummy, char *arg)
  +     set_proxy_dirconn(cmd_parms *parms, void *dummy, const char *arg)
   {
       server_rec *s = parms->server;
       proxy_server_conf *conf =
  @@ -639,7 +645,7 @@
   
       if (!found) {
       New = apr_push_array(conf->dirconn);
  -    New->name = arg;
  +    New->name = apr_pstrdup(parms->pool, arg);
       New->hostentry = NULL;
   
       if (ap_proxy_is_ipaddr(New, parms->pool)) {
  @@ -676,7 +682,7 @@
   }
   
   static const char *
  -     set_proxy_domain(cmd_parms *parms, void *dummy, char *arg)
  +     set_proxy_domain(cmd_parms *parms, void *dummy, const char *arg)
   {
       proxy_server_conf *psf =
       ap_get_module_config(parms->server->module_config, &proxy_module);
  @@ -700,7 +706,7 @@
   
   
   static const char *
  -     set_recv_buffer_size(cmd_parms *parms, void *dummy, char *arg)
  +     set_recv_buffer_size(cmd_parms *parms, void *dummy, const char *arg)
   {
       proxy_server_conf *psf =
       ap_get_module_config(parms->server->module_config, &proxy_module);
  @@ -714,7 +720,7 @@
   }
   
   static const char*
  -    set_via_opt(cmd_parms *parms, void *dummy, char *arg)
  +    set_via_opt(cmd_parms *parms, void *dummy, const char *arg)
   {
       proxy_server_conf *psf = ap_get_module_config(parms->server->module_config, &proxy_module);
   
  @@ -735,7 +741,7 @@
   }
   
   static const char*
  -    set_cache_completion(cmd_parms *parms, void *dummy, char *arg)
  +    set_cache_completion(cmd_parms *parms, void *dummy, const char *arg)
   {
       proxy_server_conf *psf = ap_get_module_config(parms->server->module_config, &proxy_module);
       int s = atoi(arg);
  @@ -757,30 +763,30 @@
   
   static const command_rec proxy_cmds[] =
   {
  -    {"ProxyRequests", set_proxy_req, NULL, RSRC_CONF, FLAG,
  -     "on if the true proxy requests should be accepted"},
  -    {"ProxyRemote", add_proxy, NULL, RSRC_CONF, TAKE2,
  -     "a scheme, partial URL or '*' and a proxy server"},
  -    {"ProxyPass", add_pass, NULL, RSRC_CONF, TAKE2,
  -     "a virtual path and a URL"},
  -    {"ProxyPassReverse", add_pass_reverse, NULL, RSRC_CONF, TAKE2,
  -     "a virtual path and a URL for reverse proxy behaviour"},
  -    {"ProxyBlock", set_proxy_exclude, NULL, RSRC_CONF, ITERATE,
  -     "A list of names, hosts or domains to which the proxy will not connect"},
  -    {"ProxyReceiveBufferSize", set_recv_buffer_size, NULL, RSRC_CONF, TAKE1,
  -     "Receive buffer size for outgoing HTTP and FTP connections in bytes"},
  -    {"NoProxy", set_proxy_dirconn, NULL, RSRC_CONF, ITERATE,
  -     "A list of domains, hosts, or subnets to which the proxy will connect directly"},
  -    {"ProxyDomain", set_proxy_domain, NULL, RSRC_CONF, TAKE1,
  -     "The default intranet domain name (in absence of a domain in the URL)"},
  -    {"AllowCONNECT", set_allowed_ports, NULL, RSRC_CONF, ITERATE,
  -     "A list of ports which CONNECT may connect to"},
  -    {"ProxyVia", set_via_opt, NULL, RSRC_CONF, TAKE1,
  -     "Configure Via: proxy header header to one of: on | off | block | full"},
  -    {"ProxyNoCache", set_cache_exclude, NULL, RSRC_CONF, ITERATE,
  -     "A list of names, hosts or domains for which caching is *not* provided"},
  -    {"ProxyForceCacheCompletion", set_cache_completion, NULL, RSRC_CONF, TAKE1,
  -     "Force a http cache completion after this percentage is loaded"},
  +    AP_INIT_FLAG("ProxyRequests", set_proxy_req, NULL, RSRC_CONF,
  +     "on if the true proxy requests should be accepted"),
  +    AP_INIT_TAKE2("ProxyRemote", add_proxy, NULL, RSRC_CONF,
  +     "a scheme, partial URL or '*' and a proxy server"),
  +    AP_INIT_TAKE2("ProxyPass", add_pass, NULL, RSRC_CONF,
  +     "a virtual path and a URL"),
  +    AP_INIT_TAKE2("ProxyPassReverse", add_pass_reverse, NULL, RSRC_CONF,
  +     "a virtual path and a URL for reverse proxy behaviour"),
  +    AP_INIT_ITERATE("ProxyBlock", set_proxy_exclude, NULL, RSRC_CONF,
  +     "A list of names, hosts or domains to which the proxy will not connect"),
  +    AP_INIT_TAKE1("ProxyReceiveBufferSize", set_recv_buffer_size, NULL, RSRC_CONF,
  +     "Receive buffer size for outgoing HTTP and FTP connections in bytes"),
  +    AP_INIT_ITERATE("NoProxy", set_proxy_dirconn, NULL, RSRC_CONF,
  +     "A list of domains, hosts, or subnets to which the proxy will connect directly"),
  +    AP_INIT_TAKE1("ProxyDomain", set_proxy_domain, NULL, RSRC_CONF,
  +     "The default intranet domain name (in absence of a domain in the URL)"),
  +    AP_INIT_ITERATE("AllowCONNECT", set_allowed_ports, NULL, RSRC_CONF,
  +     "A list of ports which CONNECT may connect to"),
  +    AP_INIT_TAKE1("ProxyVia", set_via_opt, NULL, RSRC_CONF,
  +     "Configure Via: proxy header header to one of: on | off | block | full"),
  +    AP_INIT_ITERATE("ProxyNoCache", set_cache_exclude, NULL, RSRC_CONF,
  +     "A list of names, hosts or domains for which caching is *not* provided"),
  +    AP_INIT_TAKE1("ProxyForceCacheCompletion", set_cache_completion, NULL, RSRC_CONF,
  +     "Force a http cache completion after this percentage is loaded"),
   
       {NULL}
   };
  
  
  
  1.12      +7 -7      apache-2.0/src/modules/proxy/mod_proxy.h
  
  Index: mod_proxy.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/proxy/mod_proxy.h,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- mod_proxy.h	2000/08/02 05:27:12	1.11
  +++ mod_proxy.h	2000/10/08 03:23:05	1.12
  @@ -110,9 +110,9 @@
   #include "http_config.h"
   #include "http_protocol.h"
   #include "ap_cache.h"
  -
  +/*   XXX There is no explain.h in Apache 2.0
   #include "explain.h"
  -
  +*/
   #ifdef HAVE_NETDB_H
   #include <netdb.h>
   #endif
  @@ -171,8 +171,8 @@
   };
   
   struct proxy_alias {
  -    char *real;
  -    char *fake;
  +    const char *real;
  +    const char *fake;
   };
   
   struct dirconn_entry {
  @@ -183,12 +183,12 @@
   };
   
   struct noproxy_entry {
  -    char *name;
  +    const char *name;
       struct in_addr addr;
   };
   
   struct nocache_entry {
  -    char *name;
  +    const char *name;
       struct in_addr addr;
   };
   
  @@ -200,7 +200,7 @@
       apr_array_header_t *dirconn;
       apr_array_header_t *nocaches;
       apr_array_header_t *allowed_connect_ports;
  -    char *domain;		/* domain name to use in absence of a domain name in the request */
  +    const char *domain;		/* domain name to use in absence of a domain name in the request
*/
       int req;			/* true if proxy requests are enabled */
       float cache_completion;	/* Force cache completion after this point */
       enum {
  
  
  
  1.12      +2 -1      apache-2.0/src/modules/proxy/proxy_connect.c
  
  Index: proxy_connect.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/proxy/proxy_connect.c,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- proxy_connect.c	2000/08/23 00:01:56	1.11
  +++ proxy_connect.c	2000/10/08 03:23:05	1.12
  @@ -58,6 +58,7 @@
   
   /* CONNECT method for Apache proxy */
   
  +#include "apr_strings.h"
   #include "mod_proxy.h"
   #include "http_log.h"
   #include "http_main.h"
  @@ -145,7 +146,7 @@
   /* check if ProxyBlock directive on this host */
       destaddr.s_addr = apr_inet_addr(host);
       for (i = 0; i < conf->noproxies->nelts; i++) {
  -    if ((npent[i].name != NULL && strstr(host, npent[i].name) != NULL)
  +    if ((npent[i].name != NULL && ap_strstr_c(host, npent[i].name) != NULL)
           || destaddr.s_addr == npent[i].addr.s_addr || npent[i].name[0] == '*')
           return ap_proxyerror(r, HTTP_FORBIDDEN,
                    "Connect to remote machine blocked");
  
  
  
  1.17      +10 -7     apache-2.0/src/modules/proxy/proxy_ftp.c
  
  Index: proxy_ftp.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/proxy/proxy_ftp.c,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- proxy_ftp.c	2000/08/23 00:01:56	1.16
  +++ proxy_ftp.c	2000/10/08 03:23:05	1.17
  @@ -58,6 +58,7 @@
   
   /* FTP routines for Apache proxy */
   
  +#include "apr_strings.h"
   #include "mod_proxy.h"
   #include "http_main.h"
   #include "http_log.h"
  @@ -287,7 +288,7 @@
       register int n, o, w;
       conn_rec *con = r->connection;
       char *dir, *path, *reldir, *site;
  -    BUFF *cachefp = NULL;
  +    apr_file_t *cachefp = NULL;
   
       if(c) ap_cache_el_data(c, &cachefp);
       
  @@ -398,7 +399,8 @@
       o = 0;
       total_bytes_sent += n;
   
  -    if (cachefp && ap_bwrite(cachefp, buf, n, &cntr) != n) {
  +    cntr = n;
  +    if (cachefp && apr_write(cachefp, buf, &cntr) != APR_SUCCESS) {
           ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                         "proxy: error writing to cache");
           ap_proxy_cache_error(&c);
  @@ -468,7 +470,8 @@
       int port, i, j, len, rc, nocache = 0;
       apr_socket_t *csd;
       struct in_addr destaddr;
  -    BUFF *f, *cachefp = NULL;
  +    BUFF *f;
  +    apr_file_t *cachefp = NULL;
       BUFF *data = NULL;
       apr_pool_t *p = r->pool;
       int one = 1;
  @@ -547,7 +550,7 @@
   /* check if ProxyBlock directive on this host */
       destaddr.s_addr = apr_inet_addr(host);
       for (i = 0; i < conf->noproxies->nelts; i++) {
  -    if ((npent[i].name != NULL && strstr(host, npent[i].name) != NULL)
  +    if ((npent[i].name != NULL && ap_strstr_c(host, npent[i].name) != NULL)
           || destaddr.s_addr == npent[i].addr.s_addr || npent[i].name[0] == '*')
           return ap_proxyerror(r, HTTP_FORBIDDEN,
                    "Connect to remote machine blocked");
  @@ -1116,7 +1119,7 @@
       
   /* check if NoCache directive on this host */
       for (i = 0; i < conf->nocaches->nelts; i++) {
  -    if ((ncent[i].name != NULL && strstr(host, ncent[i].name) != NULL)
  +    if ((ncent[i].name != NULL && ap_strstr_c(host, ncent[i].name) != NULL)
           || destaddr.s_addr == ncent[i].addr.s_addr || ncent[i].name[0] == '*')
           nocache = 1;
       }
  @@ -1156,7 +1159,7 @@
   /* write status line */
       if (!r->assbackwards)
       ap_rvputs(r, "HTTP/1.0 ", r->status_line, CRLF, NULL);
  -    if (cachefp    && ap_bvputs(cachefp, "HTTP/1.0 ", r->status_line, CRLF,
NULL) == -1) {
  +    if (cachefp    && apr_puts(apr_pstrcat(r->pool, "HTTP/1.0 ", r->status_line,
CRLF, NULL), cachefp) != APR_SUCCESS) {
           ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                         "proxy: error writing CRLF to cache");
           ap_proxy_cache_error(&c);
  @@ -1167,7 +1170,7 @@
       ap_cache_el_header_walk(c, ap_proxy_send_hdr_line, r, NULL);
       if (!r->assbackwards)
           ap_rputs(CRLF, r);
  -    if (cachefp && ap_bputs(CRLF, cachefp) == -1) {
  +    if (cachefp && apr_puts(CRLF, cachefp) == -1) {
           ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                         "proxy: error writing CRLF to cache");
           ap_proxy_cache_error(&c);
  
  
  
  1.16      +11 -8     apache-2.0/src/modules/proxy/proxy_http.c
  
  Index: proxy_http.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/proxy/proxy_http.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- proxy_http.c	2000/08/23 00:01:57	1.15
  +++ proxy_http.c	2000/10/08 03:23:05	1.16
  @@ -58,6 +58,7 @@
   
   /* HTTP routines for Apache proxy */
   
  +#include "apr_strings.h"
   #include "mod_proxy.h"
   #include "http_log.h"
   #include "http_main.h"
  @@ -171,7 +172,7 @@
   {
       const char *strp;
       char *strp2;
  -    const char *desthost;
  +    char *desthost;
       apr_socket_t *sock;
       int i, len, backasswards, content_length=-1;
       apr_array_header_t *reqhdrs_arr;
  @@ -179,7 +180,8 @@
       apr_table_entry_t *reqhdrs;
       struct sockaddr_in server;
       struct in_addr destaddr;
  -    BUFF *f, *cachefp=NULL;
  +    BUFF *f;
  +    apr_file_t *cachefp=NULL;
       char buffer[HUGE_STRING_LEN];
       char portstr[32];
       apr_pool_t *p = r->pool;
  @@ -207,7 +209,7 @@
           return HTTP_BAD_REQUEST;
       urlptr += 3;
       destport = DEFAULT_HTTP_PORT;
  -    strp = strchr(urlptr, '/');
  +    strp = ap_strchr_c(urlptr, '/');
       if (strp == NULL) {
           desthost = apr_pstrdup(p, urlptr);
           urlptr = "/";
  @@ -220,7 +222,7 @@
           desthost = q;
       }
   
  -    strp2 = strchr(desthost, ':');
  +    strp2 = ap_strchr(desthost, ':');
       if (strp2 != NULL) {
           *(strp2++) = '\0';
           if (apr_isdigit(*strp2)) {
  @@ -232,7 +234,7 @@
   /* check if ProxyBlock directive on this host */
       destaddr.s_addr = apr_inet_addr(desthost);
       for (i = 0; i < conf->noproxies->nelts; i++) {
  -        if ((npent[i].name != NULL && strstr(desthost, npent[i].name) != NULL)
  +        if ((npent[i].name != NULL && ap_strstr_c(desthost, npent[i].name) != NULL)
               || destaddr.s_addr == npent[i].addr.s_addr || npent[i].name[0] == '*')
               return ap_proxyerror(r, HTTP_FORBIDDEN,
                                    "Connect to remote machine blocked");
  @@ -421,7 +423,7 @@
           content_length = atoi(clen ? clen : "-1");
   
       for (i = 0; i < conf->nocaches->nelts; i++) {
  -        if ((ncent[i].name != NULL && strstr(desthost, ncent[i].name) != NULL)
  +        if ((ncent[i].name != NULL && ap_strstr_c(desthost, ncent[i].name) != NULL)
               || destaddr.s_addr == ncent[i].addr.s_addr || ncent[i].name[0] == '*')
               nocache = 1;
       }
  @@ -434,7 +436,7 @@
   /* write status line */
       if (!r->assbackwards)
           ap_rvputs(r, "HTTP/1.0 ", r->status_line, CRLF, NULL);
  -    if (cachefp &&    ap_bvputs(cachefp, "HTTP/1.0 ", r->status_line, CRLF,
NULL) == -1) {
  +    if (cachefp &&    apr_puts(apr_pstrcat(r->pool, "HTTP/1.0 ", r->status_line,
CRLF, NULL), cachefp) != APR_SUCCESS) {
           ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                         "proxy: error writing status line to cache");
           ap_proxy_cache_error(&c);
  @@ -452,7 +454,8 @@
   /* Is it an HTTP/0.9 respose? If so, send the extra data */
       if (backasswards) {
           ap_bwrite(r->connection->client, buffer, len, &cntr);
  -        if (cachefp && ap_bwrite(cachefp, buffer, len, &cntr) != len) {
  +        cntr = len;
  +        if (cachefp && apr_write(cachefp, buffer, &cntr) != APR_SUCCESS) {
               ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                             "proxy: error writing extra data to cache %ld",
                             (long)cachefp);
  
  
  
  1.19      +21 -12    apache-2.0/src/modules/proxy/proxy_util.c
  
  Index: proxy_util.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/proxy/proxy_util.c,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- proxy_util.c	2000/08/06 06:07:45	1.18
  +++ proxy_util.c	2000/10/08 03:23:05	1.19
  @@ -57,6 +57,7 @@
    */
   
   /* Utility routines for Apache proxy */
  +#include "apr_strings.h"
   #include "mod_proxy.h"
   #include "http_main.h"
   #include "apr_md5.h"
  @@ -141,8 +142,8 @@
   {
       int i, j, ch;
       char *y;
  -    const char *allowed;    /* characters which should not be encoded */
  -    const char *reserved;    /* characters which much not be en/de-coded */
  +    char *allowed;    /* characters which should not be encoded */
  +    char *reserved;    /* characters which much not be en/de-coded */
   
   /* N.B. in addition to :@&=, this allows ';' in an http path
    * and '?' in an ftp path -- this may be revised
  @@ -311,8 +312,9 @@
    * formatted, then it exits very quickly.
    */
   const char *
  -     ap_proxy_date_canon(apr_pool_t *p, const char *x)
  +     ap_proxy_date_canon(apr_pool_t *p, const char *x1)
   {
  +    char *x = apr_pstrdup(p, x1);
       int wk, mday, year, hour, min, sec, mon;
       char *q, month[4], zone[4], week[4];
   
  @@ -500,7 +502,7 @@
       register int n, o;
       conn_rec *con = r->connection;
       int alternate_timeouts = 1;    /* 1 if we alternate between soft & hard timeouts
*/
  -    BUFF *cachefp = NULL;
  +    apr_file_t *cachefp = NULL;
       int written = 0, wrote_to_cache;
       
       total_bytes_rcvd = 0;
  @@ -554,7 +556,8 @@
       
           /* Write to cache first. */
           /*@@@ XXX FIXME: Assuming that writing the cache file won't time out?!!? */
  -        if (cachefp && ap_bwrite(cachefp, &buf[0], cntr, &wrote_to_cache)
!= APR_SUCCESS) {
  +        wrote_to_cache = cntr;
  +        if (cachefp && apr_write(cachefp, &buf[0], &wrote_to_cache) !=
APR_SUCCESS) {
               ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                             "proxy: error writing to cache");
               ap_proxy_cache_error(&c);
  @@ -636,7 +639,7 @@
       len = strlen(val);
   
       while (list != NULL) {
  -    p = strchr(list, ',');
  +    p = ap_strchr_c(list, ',');
       if (p != NULL) {
           i = p - list;
           do
  @@ -1125,7 +1128,7 @@
   static int proxy_match_word(struct dirconn_entry *This, request_rec *r)
   {
       const char *host = proxy_get_host_of_request(r);
  -    return host != NULL && strstr(host, This->name) != NULL;
  +    return host != NULL && ap_strstr_c(host, This->name) != NULL;
   }
   
   int ap_proxy_doconnect(apr_socket_t *sock, char *host, apr_uint32_t port, request_rec *r)
  @@ -1173,16 +1176,17 @@
   unsigned ap_proxy_bputs2(const char *data, BUFF *client, ap_cache_el  *cache)
   {
       unsigned len = ap_bputs(data, client);
  -    BUFF *cachefp = NULL;
  +    apr_file_t *cachefp = NULL;
       
       if (ap_cache_el_data(cache, &cachefp) == APR_SUCCESS)
  -        ap_bputs(data, cachefp);
  +        apr_puts(data, cachefp);
       return len;
   }
   
   int ap_proxy_cache_send(request_rec *r, ap_cache_el *c)
   {
  -    BUFF *cachefp = NULL, *fp = r->connection->client;
  +    apr_file_t *cachefp = NULL;
  +    BUFF *fp = r->connection->client;
       char buffer[500];
       
       ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, NULL,
  @@ -1190,13 +1194,18 @@
       if(ap_cache_el_data(c, &cachefp) != APR_SUCCESS)
           return HTTP_INTERNAL_SERVER_ERROR;
       /* send the response */
  -    if(ap_bgets(buffer, sizeof(buffer), cachefp))
  +    if(apr_fgets(buffer, sizeof(buffer), cachefp))
           ap_bvputs(fp, buffer, NULL);
       /* send headers */
       ap_cache_el_header_walk(c, ap_proxy_send_hdr_line, r, NULL);
       ap_bputs(CRLF, fp);
       /* send data */
  -    if(!r->header_only && !ap_proxy_send_fb(0, cachefp, r, NULL))
  +    /* XXX I changed the ap_proxy_send_fb call to use fp instead of cachefp.
  +     *     this compiles cleanly, but it is probably the completely wrong
  +     *     solution.  We need to go through the proxy code, and remove all
  +     *     of the BUFF's.  rbb
  +     */
  +    if(!r->header_only && !ap_proxy_send_fb(0, fp, r, NULL))
           return HTTP_INTERNAL_SERVER_ERROR;
       return OK;
   }
  
  
  

Mime
View raw message