sha1_file: guard against invalid loose subdirectory numbers

Loose object subdirectories have hexadecimal names based on the first
byte of the hash of contained objects, thus their numerical
representation can range from 0 (0x00) to 255 (0xff).  Change the type
of the corresponding variable in for_each_file_in_obj_subdir() and
associated callback functions to unsigned int and add a range check.

Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
René Scharfe
2017-06-24 16:09:39 +02:00
committed by Junio C Hamano
parent 0375f472d4
commit 70c49050d4
5 changed files with 9 additions and 6 deletions

View File

@ -537,7 +537,7 @@ static int fsck_cruft(const char *basename, const char *path, void *data)
return 0;
}
static int fsck_subdir(int nr, const char *path, void *progress)
static int fsck_subdir(unsigned int nr, const char *path, void *progress)
{
display_progress(progress, nr + 1);
return 0;