Skip to content

Commit 8f43e25

Browse files
committed
mod_proxy_http2: fix potential (harmless) buffer overrun in link mapping
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1933903 13f79535-47bb-0310-9956-ffa450edef68
1 parent 96ed77c commit 8f43e25

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

modules/http2/h2_proxy_util.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -966,11 +966,8 @@ static void map_link(link_ctx *ctx)
966966
apr_cpystrn(buffer, ctx->p_server_uri, sizeof(buffer));
967967
buffer_len = ctx->psu_len;
968968
}
969-
if (need_len > sizeof(buffer)) {
970-
ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, ctx->r, APLOGNO(03482)
971-
"link_reverse_map uri too long, skipped: %s", ctx->s);
972-
return;
973-
}
969+
if (need_len > sizeof(buffer))
970+
goto out;
974971
apr_cpystrn(buffer + buffer_len, ctx->s + ctx->link_start, link_len + 1);
975972
if (!prepend_p_server
976973
&& strcmp(ctx->real_backend_uri, ctx->p_server_uri)
@@ -979,6 +976,9 @@ static void map_link(link_ctx *ctx)
979976
* to work, we need to use the proxy uri */
980977
int path_start = ctx->link_start + ctx->rbu_len;
981978
link_len -= ctx->rbu_len;
979+
need_len = ctx->psu_len + link_len;
980+
if (need_len > sizeof(buffer))
981+
goto out;
982982
memcpy(buffer, ctx->p_server_uri, ctx->psu_len);
983983
memcpy(buffer + ctx->psu_len, ctx->s + path_start, link_len);
984984
buffer_len = ctx->psu_len + link_len;
@@ -999,6 +999,11 @@ static void map_link(link_ctx *ctx)
999999
}
10001000
subst_str(ctx, ctx->link_start, ctx->link_end, mapped);
10011001
}
1002+
out:
1003+
if (need_len > sizeof(buffer)) {
1004+
ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, ctx->r, APLOGNO(03482)
1005+
"link_reverse_map uri too long, skipped: %s", ctx->s);
1006+
}
10021007
}
10031008
}
10041009

0 commit comments

Comments
 (0)