|
|
8b0621 |
diff --git a/modules/metadata/mod_remoteip.c b/modules/metadata/mod_remoteip.c
|
|
|
8b0621 |
index 4572ce1..a0cbc0f 100644
|
|
|
8b0621 |
--- a/modules/metadata/mod_remoteip.c
|
|
|
8b0621 |
+++ b/modules/metadata/mod_remoteip.c
|
|
|
8b0621 |
@@ -987,15 +987,13 @@ static remoteip_parse_status_t remoteip_process_v2_header(conn_rec *c,
|
|
|
8b0621 |
return HDR_ERROR;
|
|
|
8b0621 |
#endif
|
|
|
8b0621 |
default:
|
|
|
8b0621 |
- /* unsupported protocol, keep local connection address */
|
|
|
8b0621 |
- return HDR_DONE;
|
|
|
8b0621 |
+ /* unsupported protocol */
|
|
|
8b0621 |
+ ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, c, APLOGNO(10183)
|
|
|
8b0621 |
+ "RemoteIPProxyProtocol: unsupported protocol %.2hx",
|
|
|
8b0621 |
+ (unsigned short)hdr->v2.fam);
|
|
|
8b0621 |
+ return HDR_ERROR;
|
|
|
8b0621 |
}
|
|
|
8b0621 |
break; /* we got a sockaddr now */
|
|
|
8b0621 |
-
|
|
|
8b0621 |
- case 0x00: /* LOCAL command */
|
|
|
8b0621 |
- /* keep local connection address for LOCAL */
|
|
|
8b0621 |
- return HDR_DONE;
|
|
|
8b0621 |
-
|
|
|
8b0621 |
default:
|
|
|
8b0621 |
/* not a supported command */
|
|
|
8b0621 |
ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, c, APLOGNO(03507)
|
|
|
8b0621 |
@@ -1087,11 +1085,24 @@ static apr_status_t remoteip_input_filter(ap_filter_t *f,
|
|
|
8b0621 |
/* try to read a header's worth of data */
|
|
|
8b0621 |
while (!ctx->done) {
|
|
|
8b0621 |
if (APR_BRIGADE_EMPTY(ctx->bb)) {
|
|
|
8b0621 |
- ret = ap_get_brigade(f->next, ctx->bb, ctx->mode, block,
|
|
|
8b0621 |
- ctx->need - ctx->rcvd);
|
|
|
8b0621 |
+ apr_off_t got, want = ctx->need - ctx->rcvd;
|
|
|
8b0621 |
+
|
|
|
8b0621 |
+ ret = ap_get_brigade(f->next, ctx->bb, ctx->mode, block, want);
|
|
|
8b0621 |
if (ret != APR_SUCCESS) {
|
|
|
8b0621 |
+ ap_log_cerror(APLOG_MARK, APLOG_ERR, ret, f->c, APLOGNO(10184)
|
|
|
8b0621 |
+ "failed reading input");
|
|
|
8b0621 |
return ret;
|
|
|
8b0621 |
}
|
|
|
8b0621 |
+
|
|
|
8b0621 |
+ ret = apr_brigade_length(ctx->bb, 1, &got;;
|
|
|
8b0621 |
+ if (ret || got > want) {
|
|
|
8b0621 |
+ ap_log_cerror(APLOG_MARK, APLOG_ERR, ret, f->c, APLOGNO(10185)
|
|
|
8b0621 |
+ "RemoteIPProxyProtocol header too long, "
|
|
|
8b0621 |
+ "got %" APR_OFF_T_FMT " expected %" APR_OFF_T_FMT,
|
|
|
8b0621 |
+ got, want);
|
|
|
8b0621 |
+ f->c->aborted = 1;
|
|
|
8b0621 |
+ return APR_ECONNABORTED;
|
|
|
8b0621 |
+ }
|
|
|
8b0621 |
}
|
|
|
8b0621 |
if (APR_BRIGADE_EMPTY(ctx->bb)) {
|
|
|
8b0621 |
return block == APR_NONBLOCK_READ ? APR_SUCCESS : APR_EOF;
|
|
|
8b0621 |
@@ -1139,6 +1150,13 @@ static apr_status_t remoteip_input_filter(ap_filter_t *f,
|
|
|
8b0621 |
if (ctx->rcvd >= MIN_V2_HDR_LEN) {
|
|
|
8b0621 |
ctx->need = MIN_V2_HDR_LEN +
|
|
|
8b0621 |
remoteip_get_v2_len((proxy_header *) ctx->header);
|
|
|
8b0621 |
+ if (ctx->need > sizeof(proxy_v2)) {
|
|
|
8b0621 |
+ ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, f->c, APLOGNO(10186)
|
|
|
8b0621 |
+ "RemoteIPProxyProtocol protocol header length too long");
|
|
|
8b0621 |
+ f->c->aborted = 1;
|
|
|
8b0621 |
+ apr_brigade_destroy(ctx->bb);
|
|
|
8b0621 |
+ return APR_ECONNABORTED;
|
|
|
8b0621 |
+ }
|
|
|
8b0621 |
}
|
|
|
8b0621 |
if (ctx->rcvd >= ctx->need) {
|
|
|
8b0621 |
psts = remoteip_process_v2_header(f->c, conn_conf,
|