Max Kirillov <[email protected]> writes:
> I'm afraid I did not get the reasonsing and not fully the
> desired change. Is this http-backend code change (compared
> to the last patch) what you mean?
Exactly.
The fact that the parsed string happens to come from CONTENT_LENGTH
environment variable is http's business, not parsers for various
types of values that come in the form of strings.
> --- a/http-backend.c
> +++ b/http-backend.c
> @@ -346,9 +346,18 @@ static ssize_t read_request_fixed_len(int fd, ssize_t
> req_len, unsigned char **o
> }
> }
>
> +static ssize_t env_content_length()
We need s/length()/length(void)/; though.
> +{
> + const char *str = getenv("CONTENT_LENGTH");
> + ssize_t val = -1;
> + if (str && !git_parse_ssize_t(str, &val))
> + die("failed to parse CONTENT_LENGTH: %s", str);
> + return val;
> +}
> +
> static ssize_t read_request(int fd, unsigned char **out)
> {
> - ssize_t req_len = git_env_ssize_t("CONTENT_LENGTH", -1);
> + ssize_t req_len = env_content_length();
> if (req_len < 0)
> return read_request_eof(fd, out);
> else