Skip to content

mod_proxy_http2: reserve NUL when rewriting a backend Link header uri - #711

Open
arshsmith1 wants to merge 1 commit into
apache:trunkfrom
arshsmith1:h2-proxy-link-map-off-by-one
Open

mod_proxy_http2: reserve NUL when rewriting a backend Link header uri#711
arshsmith1 wants to merge 1 commit into
apache:trunkfrom
arshsmith1:h2-proxy-link-map-off-by-one

Conversation

@arshsmith1

Copy link
Copy Markdown

map_link() in h2_proxy_util.c rewrites the URI of a backend Link response header into a fixed HUGE_STRING_LEN stack buffer. In the branch that swaps the real backend uri for the proxy uri, need_len is computed as psu_len + link_len without the +1 the sibling branch a few lines above uses to reserve the terminating NUL, so the oversize guard admits need_len == sizeof(buffer) and the following buffer[buffer_len] = '\0' writes one byte past the array. A reverse proxy over HTTP/2 with ProxyPreserveHost off reaches this when a backend returns a Link header whose absolute URI is sized so psu_len + (link_len - rbu_len) equals 8192. Adding the +1 makes the check reserve room for the NUL, matching the other branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant