When message headers are formatted, the connection and upgrade header values
are parsed to be sanitized and to fill H1M flags. The values are modified in
place without changing the HTX message information accordingly (the block
info and the HTX info). It could be an issue if the output buffer is full
and the header cannot be formatted. Because the formatting can be stopped
with a HTX message in hazardous state.
It should be quite difficult to trigger this issue. But now, a copy of the
value is performed before parsing it. So only the copy will be altered,
leaving the HTX message in a safe state.
This patch must be backported to all stable versions.
h1s->flags |= H1S_F_HAVE_CLEN;
}
else if (isteq(n, ist("connection"))) {
+ /* copy the value because it can be modified, but the HTX blocks will not */
+ memcpy(trash.area, v.ptr, v.len);
+ v.ptr = trash.area;
h1_parse_connection_header(h1m, &v);
if (!v.len)
goto nextblk;
}
else if (isteq(n, ist("upgrade"))) {
+ /* copy the value because it can be modified, but the HTX blocks will not */
+ memcpy(trash.area, v.ptr, v.len);
+ v.ptr = trash.area;
h1_parse_upgrade_header(h1m, &v);
if (!v.len)
goto nextblk;