diff options
| author | Patrick Steinhardt <ps@pks.im> | 2024-08-01 12:42:59 +0200 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-08-01 08:47:35 -0700 |
| commit | 5535b3f3d3eaafa872514af05f021ae6d00f83dc (patch) | |
| tree | e0d7d03f63a9e4f1d49cb6f0c4a98430c170a26c /commit-reach.c | |
| parent | builtin/name-rev: fix various trivial memory leaks (diff) | |
| download | git-5535b3f3d3eaafa872514af05f021ae6d00f83dc.tar.gz git-5535b3f3d3eaafa872514af05f021ae6d00f83dc.zip | |
builtin/submodule--helper: fix leaking clone depth parameter
The submodule helper supports a `--depth` parameter for both its "add"
and "clone" subcommands, which in both cases end up being forwarded to
git-clone(1). But while the former subcommand uses an `OPT_INTEGER()` to
parse the depth, the latter uses `OPT_STRING()`. Consequently, it is
possible to pass non-integer input to "--depth" when calling the "clone"
subcommand, where the value will then ultimately cause git-clone(1) to
bail out.
Besides the fact that the parameter verification should happen earlier,
the submodule helper infrastructure also internally tracks the depth via
a string. This requires us to convert the integer in the "add"
subcommand into an allocated string, and this string ultimately leaks.
Refactor the code to consistently track the clone depth as an integer.
This plugs the memory leak, simplifies the code and allows us to use
`OPT_INTEGER()` instead of `OPT_STRING()`, validating the input before
we shell out to git--clone(1).
Original-patch-by: Rubén Justo <rjusto@gmail.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit-reach.c')
0 files changed, 0 insertions, 0 deletions
