Re: [PATCH v7 08/12] test-http-server: add simple authentication
- From
Jeff King <peff@peff.net>
- Date
- Jan 26, 2023, 20:33 UTC
- Message-ID
- <Y9LjmMWjBQgNTsQq@coredump.intra.peff.net>
- In-Reply-To
- <b8d3e81b5534148359c7e92807cf1e2795480ddf.1674252531.git.gitgitgadget@gmail.com>
On Fri, Jan 20, 2023 at 10:08:46PM +0000, Matthew John Cheetham via GitGitGadget wrote:
Show 17 quoted lines
> +static int split_auth_param(const char *str, char **scheme, char **val)
> +{
> + struct strbuf **p = strbuf_split_str(str, ':', 2);
> +
> + if (!p[0])
> + return -1;
> +
> + /* trim trailing ':' */
> + if (p[0]->len && p[0]->buf[p[0]->len - 1] == ':')
> + strbuf_setlen(p[0], p[0]->len - 1);
> +
> + *scheme = strbuf_detach(p[0], NULL);
> + *val = p[1] ? strbuf_detach(p[1], NULL) : NULL;
> +
> + strbuf_list_free(p);
> + return 0;
> +}Oh, I forgot one more Coverity-detected problem here when reviewing last night. The early "return -1" here leaks "p" (there are no strbufs in the resulting array, but strbuf_split_str() will still have allocated the array). It needs a call to strbuf_list_free(p) there.
-Peff