A client request can make the FastCGI path copy exactly fill its
scratch buffer. b_tail() then wraps to the start, so subtracting the
path length points before the buffer. URL decoding reads and writes
there instead of reading the copied path.
Require one free byte for ist0()'s terminator. The request then
follows the existing error path; ordinary paths keep working.
Commit
a01ba66bc2 rejected oversized copies but missed exact fits.
This should be backported to affected stable branches.
Signed-off-by: Kelly Kane <kelly@hawknetworks.com>
}
/* Decode the path. it must first be copied to keep the URI
- * untouched.
+ * untouched. Keep room for the terminating zero added by ist0().
*/
- if (!chunk_istcat(params->p, path))
+ if (path.len >= b_room(params->p) || !chunk_istcat(params->p, path))
goto error;
path.ptr = b_tail(params->p) - path.len;
len = url_decode(ist0(path), 0);