mbox series

[0/3] some minor memory allocation cleanups

Message ID 20200130095155.GA839988@coredump.intra.peff.net (mailing list archive)
Headers show
Series some minor memory allocation cleanups | expand

Message

Jeff King Jan. 30, 2020, 9:51 a.m. UTC
These are a result of me poking at the results of:

  git grep 'x[mc]alloc.*[+*] '

looking for any buffer allocation computations that could overflow (and
hence under-allocate).

There are a few hits left after this in the commit-graph code. Those
will be dealt with in a separate series (coming soon!) since they have
other problems, as discussed in:

  https://lore.kernel.org/git/20191027042116.GA5801@sigill.intra.peff.net/

(those have to do with normalize_path_copy(), hence the only
semi-related documentation patch here).

  [1/3]: normalize_path_copy(): document "dst" size expectations
  [2/3]: walker_fetch(): avoid raw array length computation
  [3/3]: traverse_trees(): use stack array for name entries

 path.c      |  2 ++
 tree-walk.c | 13 ++++++++-----
 walker.c    |  4 +++-
 3 files changed, 13 insertions(+), 6 deletions(-)

-Peff

Comments

Elijah Newren Jan. 30, 2020, 2:59 p.m. UTC | #1
On Thu, Jan 30, 2020 at 1:53 AM Jeff King <peff@peff.net> wrote:
>
> These are a result of me poking at the results of:
>
>   git grep 'x[mc]alloc.*[+*] '
>
> looking for any buffer allocation computations that could overflow (and
> hence under-allocate).
>
> There are a few hits left after this in the commit-graph code. Those
> will be dealt with in a separate series (coming soon!) since they have
> other problems, as discussed in:
>
>   https://lore.kernel.org/git/20191027042116.GA5801@sigill.intra.peff.net/
>
> (those have to do with normalize_path_copy(), hence the only
> semi-related documentation patch here).
>
>   [1/3]: normalize_path_copy(): document "dst" size expectations
>   [2/3]: walker_fetch(): avoid raw array length computation
>   [3/3]: traverse_trees(): use stack array for name entries
>
>  path.c      |  2 ++
>  tree-walk.c | 13 ++++++++-----
>  walker.c    |  4 +++-
>  3 files changed, 13 insertions(+), 6 deletions(-)
>
> -Peff

Other than introducing (or extending?) a cyclic dependency between
tree-walk and unpack-trees that I'd prefer to remove, this series
looks good to me.
Taylor Blau Jan. 30, 2020, 11:03 p.m. UTC | #2
Hi Peff,

On Thu, Jan 30, 2020 at 04:51:55AM -0500, Jeff King wrote:
> These are a result of me poking at the results of:
>
>   git grep 'x[mc]alloc.*[+*] '
>
> looking for any buffer allocation computations that could overflow (and
> hence under-allocate).
>
> There are a few hits left after this in the commit-graph code. Those
> will be dealt with in a separate series (coming soon!) since they have
> other problems, as discussed in:

I just sent the series you're referring to in [1].

>   https://lore.kernel.org/git/20191027042116.GA5801@sigill.intra.peff.net/
>
> (those have to do with normalize_path_copy(), hence the only
> semi-related documentation patch here).
>
>   [1/3]: normalize_path_copy(): document "dst" size expectations
>   [2/3]: walker_fetch(): avoid raw array length computation
>   [3/3]: traverse_trees(): use stack array for name entries
>
>  path.c      |  2 ++
>  tree-walk.c | 13 ++++++++-----
>  walker.c    |  4 +++-
>  3 files changed, 13 insertions(+), 6 deletions(-)
>
> -Peff

[1]: https://lore.kernel.org/git/cover.1580424766.git.me@ttaylorr.com/

Thanks,
Taylor