Skip to content

Commit 97a41a0

Browse files
dreamergitster
authored andcommitted
cache: clear whole hash buffer with oidclr
As long as GIT_SHA1_RAWSZ is equal to GIT_MAX_RAWSZ there's no problem, but when new hashing algorithm will be in place this memset will clear only 20-byte prefix of hash buffer. Alternatively, hashclr implementation could be adjusted, but this function is almost removed from codebase already. Separate implementation of oidclr prevents potential buffer overrun in case someone incorrectly used hashclr on object_id in future. Signed-off-by: Patryk Obara <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f070fac commit 97a41a0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ static inline void hashclr(unsigned char *hash)
10291029

10301030
static inline void oidclr(struct object_id *oid)
10311031
{
1032-
hashclr(oid->hash);
1032+
memset(oid->hash, 0, GIT_MAX_RAWSZ);
10331033
}
10341034

10351035

0 commit comments

Comments
 (0)