]> git.99rst.org Git - git.git/commit
packfile.c: use checked arithmetic in `nth_packed_object_offset()`
authorTaylor Blau <redacted>
Wed, 12 Jul 2023 23:37:32 +0000 (19:37 -0400)
committerJunio C Hamano <redacted>
Fri, 14 Jul 2023 16:32:03 +0000 (09:32 -0700)
commita519abca02eeca7dce864717b9664c62a124e1c0
tree0c229295314569b43ec13fa53e2e1044a74e9ccf
parent42be681b33ef73be056fb99e3c63c6e9b9c2e7ef
packfile.c: use checked arithmetic in `nth_packed_object_offset()`

In a similar spirit as the previous commits, ensure that we use
`st_add()` or `st_mult()` when computing values that may overflow the
32-bit unsigned limit.

Note that in each of these instances, we prevent 32-bit overflow
already since we have explicit casts to `size_t`.

So this code is OK as-is, but let's clarify it by using the `st_xyz()`
helpers to make it obvious that we are performing the relevant
computations using 64 bits.

Signed-off-by: Taylor Blau <redacted>
Signed-off-by: Junio C Hamano <redacted>
packfile.c
git clone https://git.99rst.org/PROJECT