mirror of
https://github.com/apache/httpd.git
synced 2025-08-08 15:02:10 +03:00
Compiler warnings - yuck!
Moved ap_proxy_string_read() to proxy_util.c so it can be used by proxy_http.c PR: Obtained from: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@88777 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -210,7 +210,6 @@ apr_status_t ap_proxy_null_filter(ap_filter_t *f, apr_bucket_brigade *bb);
|
|||||||
int ap_proxy_ftp_canon(request_rec *r, char *url);
|
int ap_proxy_ftp_canon(request_rec *r, char *url);
|
||||||
int ap_proxy_ftp_handler(request_rec *r, char *url);
|
int ap_proxy_ftp_handler(request_rec *r, char *url);
|
||||||
apr_status_t ap_proxy_send_dir_filter(ap_filter_t *f, apr_bucket_brigade *bb);
|
apr_status_t ap_proxy_send_dir_filter(ap_filter_t *f, apr_bucket_brigade *bb);
|
||||||
apr_status_t ap_proxy_string_read(conn_rec *c, apr_bucket_brigade *bb, char *buff, size_t bufflen);
|
|
||||||
|
|
||||||
|
|
||||||
/* proxy_http.c */
|
/* proxy_http.c */
|
||||||
@@ -243,5 +242,6 @@ int ap_proxy_is_hostname(struct dirconn_entry *This, apr_pool_t *p);
|
|||||||
int ap_proxy_is_word(struct dirconn_entry *This, apr_pool_t *p);
|
int ap_proxy_is_word(struct dirconn_entry *This, apr_pool_t *p);
|
||||||
int ap_proxy_checkproxyblock(request_rec *r, proxy_server_conf *conf, apr_sockaddr_t *uri_addr);
|
int ap_proxy_checkproxyblock(request_rec *r, proxy_server_conf *conf, apr_sockaddr_t *uri_addr);
|
||||||
int ap_proxy_pre_http_connection(conn_rec *c, request_rec *r);
|
int ap_proxy_pre_http_connection(conn_rec *c, request_rec *r);
|
||||||
|
apr_status_t ap_proxy_string_read(conn_rec *c, apr_bucket_brigade *bb, char *buff, size_t bufflen);
|
||||||
|
|
||||||
#endif /*MOD_PROXY_H*/
|
#endif /*MOD_PROXY_H*/
|
||||||
|
@@ -183,58 +183,6 @@ int ap_proxy_ftp_canon(request_rec *r, char *url)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
apr_status_t ap_proxy_string_read(conn_rec *c, apr_bucket_brigade *bb, char *buff, size_t bufflen);
|
|
||||||
|
|
||||||
/* converts a series of buckets into a string */
|
|
||||||
apr_status_t ap_proxy_string_read(conn_rec *c, apr_bucket_brigade *bb, char *buff, size_t bufflen)
|
|
||||||
{
|
|
||||||
apr_bucket *e;
|
|
||||||
apr_status_t rv;
|
|
||||||
char *pos = buff;
|
|
||||||
char *response;
|
|
||||||
int found = 0;
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
/* start with an empty string */
|
|
||||||
buff[0] = 0;
|
|
||||||
|
|
||||||
/* get line-at-a-time */
|
|
||||||
c->remain = 0;
|
|
||||||
|
|
||||||
/* loop through each brigade */
|
|
||||||
while (!found) {
|
|
||||||
|
|
||||||
/* get brigade from network */
|
|
||||||
if (APR_SUCCESS != (rv = ap_get_brigade(c->input_filters, bb, AP_MODE_BLOCKING))) {
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* loop through each bucket */
|
|
||||||
while (!found && !APR_BRIGADE_EMPTY(bb)) {
|
|
||||||
e = APR_BRIGADE_FIRST(bb);
|
|
||||||
if (APR_SUCCESS != apr_bucket_read(e, (const char **)&response, &len, APR_BLOCK_READ)) {
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
/* is string LF terminated? */
|
|
||||||
if (memchr(response, APR_ASCII_LF, len)) {
|
|
||||||
found = 1;
|
|
||||||
}
|
|
||||||
/* concat strings until buff is full - then throw the data away */
|
|
||||||
if (len > ((bufflen-1)-(pos-buff))) {
|
|
||||||
len = (bufflen-1)-(pos-buff);
|
|
||||||
}
|
|
||||||
if (len > 0) {
|
|
||||||
pos = apr_cpystrn(pos, response, len);
|
|
||||||
}
|
|
||||||
APR_BUCKET_REMOVE(e);
|
|
||||||
apr_bucket_destroy(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return APR_SUCCESS;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* we chop lines longer than 80 characters */
|
/* we chop lines longer than 80 characters */
|
||||||
#define MAX_LINE_LEN 80
|
#define MAX_LINE_LEN 80
|
||||||
|
|
||||||
@@ -244,7 +192,7 @@ apr_status_t ap_proxy_string_read(conn_rec *c, apr_bucket_brigade *bb, char *buf
|
|||||||
*/
|
*/
|
||||||
static int ftp_getrc_msg(conn_rec *c, apr_bucket_brigade *bb, char *msgbuf, int msglen)
|
static int ftp_getrc_msg(conn_rec *c, apr_bucket_brigade *bb, char *msgbuf, int msglen)
|
||||||
{
|
{
|
||||||
int len = 0, status;
|
int status;
|
||||||
char response[MAX_LINE_LEN];
|
char response[MAX_LINE_LEN];
|
||||||
char buff[5];
|
char buff[5];
|
||||||
char *mb = msgbuf,
|
char *mb = msgbuf,
|
||||||
@@ -263,30 +211,13 @@ static int ftp_getrc_msg(conn_rec *c, apr_bucket_brigade *bb, char *msgbuf, int
|
|||||||
|
|
||||||
mb = apr_cpystrn(mb, response+4, me - mb);
|
mb = apr_cpystrn(mb, response+4, me - mb);
|
||||||
|
|
||||||
ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, c->base_server,
|
|
||||||
"proxy: FTP: line [%s]", response);
|
|
||||||
|
|
||||||
if (response[3] == '-') {
|
if (response[3] == '-') {
|
||||||
memcpy(buff, response, 3);
|
memcpy(buff, response, 3);
|
||||||
buff[3] = ' ';
|
buff[3] = ' ';
|
||||||
do {
|
do {
|
||||||
|
|
||||||
if (APR_SUCCESS != (rv = ap_proxy_string_read(c, bb, response, sizeof(response)))) {
|
if (APR_SUCCESS != (rv = ap_proxy_string_read(c, bb, response, sizeof(response)))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
len = strlen(response);
|
|
||||||
if (len == 0) {
|
|
||||||
ap_log_error(APLOG_MARK, APLOG_ERR, rv, c->base_server,
|
|
||||||
"proxy: FTP: apr_bucket_read() returned zero data [%s]", response);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else if ((len < 4) && (' ' != response[0])) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, c->base_server,
|
|
||||||
"proxy: FTP: line [%s]", response);
|
|
||||||
|
|
||||||
mb = apr_cpystrn(mb, response + (' ' == response[0] ? 1 : 4), me - mb);
|
mb = apr_cpystrn(mb, response + (' ' == response[0] ? 1 : 4), me - mb);
|
||||||
} while (memcmp(response, buff, 4) != 0);
|
} while (memcmp(response, buff, 4) != 0);
|
||||||
}
|
}
|
||||||
@@ -497,7 +428,7 @@ int ap_proxy_ftp_handler(request_rec *r, char *url)
|
|||||||
apr_bucket *e;
|
apr_bucket *e;
|
||||||
apr_bucket_brigade *bb = apr_brigade_create(p);
|
apr_bucket_brigade *bb = apr_brigade_create(p);
|
||||||
apr_bucket_brigade *cbb = apr_brigade_create(p);
|
apr_bucket_brigade *cbb = apr_brigade_create(p);
|
||||||
char *buf, *pasv, *connectname;
|
char *buf, *connectname;
|
||||||
apr_port_t connectport;
|
apr_port_t connectport;
|
||||||
char buffer[MAX_STRING_LEN];
|
char buffer[MAX_STRING_LEN];
|
||||||
char *path, *strp, *parms;
|
char *path, *strp, *parms;
|
||||||
@@ -957,7 +888,7 @@ int ap_proxy_ftp_handler(request_rec *r, char *url)
|
|||||||
return ap_proxyerror(r, HTTP_BAD_GATEWAY, buffer);
|
return ap_proxyerror(r, HTTP_BAD_GATEWAY, buffer);
|
||||||
}
|
}
|
||||||
else if (i == 227) {
|
else if (i == 227) {
|
||||||
unsigned int presult, h0, h1, h2, h3, p0, p1;
|
unsigned int h0, h1, h2, h3, p0, p1;
|
||||||
char *pstr;
|
char *pstr;
|
||||||
|
|
||||||
pstr = apr_pstrdup(p, buffer);
|
pstr = apr_pstrdup(p, buffer);
|
||||||
@@ -1018,7 +949,7 @@ int ap_proxy_ftp_handler(request_rec *r, char *url)
|
|||||||
/* and try the regular way */
|
/* and try the regular way */
|
||||||
apr_socket_close(remote_sock);
|
apr_socket_close(remote_sock);
|
||||||
}
|
}
|
||||||
bypass:
|
/*bypass:*/
|
||||||
|
|
||||||
/* set up data connection */
|
/* set up data connection */
|
||||||
if (!pasvmode) {
|
if (!pasvmode) {
|
||||||
|
@@ -1081,6 +1081,55 @@ int ap_proxy_pre_http_connection(conn_rec *c, request_rec *r)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* converts a series of buckets into a string */
|
||||||
|
apr_status_t ap_proxy_string_read(conn_rec *c, apr_bucket_brigade *bb, char *buff, size_t bufflen)
|
||||||
|
{
|
||||||
|
apr_bucket *e;
|
||||||
|
apr_status_t rv;
|
||||||
|
char *pos = buff;
|
||||||
|
char *response;
|
||||||
|
int found = 0;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
/* start with an empty string */
|
||||||
|
buff[0] = 0;
|
||||||
|
|
||||||
|
/* get line-at-a-time */
|
||||||
|
c->remain = 0;
|
||||||
|
|
||||||
|
/* loop through each brigade */
|
||||||
|
while (!found) {
|
||||||
|
|
||||||
|
/* get brigade from network */
|
||||||
|
if (APR_SUCCESS != (rv = ap_get_brigade(c->input_filters, bb, AP_MODE_BLOCKING))) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* loop through each bucket */
|
||||||
|
while (!found && !APR_BRIGADE_EMPTY(bb)) {
|
||||||
|
e = APR_BRIGADE_FIRST(bb);
|
||||||
|
if (APR_SUCCESS != apr_bucket_read(e, (const char **)&response, &len, APR_BLOCK_READ)) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
/* is string LF terminated? */
|
||||||
|
if (memchr(response, APR_ASCII_LF, len)) {
|
||||||
|
found = 1;
|
||||||
|
}
|
||||||
|
/* concat strings until buff is full - then throw the data away */
|
||||||
|
if (len > ((bufflen-1)-(pos-buff))) {
|
||||||
|
len = (bufflen-1)-(pos-buff);
|
||||||
|
}
|
||||||
|
if (len > 0) {
|
||||||
|
pos = apr_cpystrn(pos, response, len);
|
||||||
|
}
|
||||||
|
APR_BUCKET_REMOVE(e);
|
||||||
|
apr_bucket_destroy(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return APR_SUCCESS;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#if defined WIN32
|
#if defined WIN32
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user