Re: [PATCH 1/3] untracked-cache: be defensive about missing NULs in index

2019-04-19 Thread Junio C Hamano
Jeff King writes: > - len = strlen((const char *)data); > - next = data + len + 1; > - if (next > rd->end) > + eos = memchr(data, '\0', end - data); > + if (!eos || eos == end) > return -1; > + len = eos - data; > + next = eos + 1; Yup, much nicer. > -

[PATCH 1/3] untracked-cache: be defensive about missing NULs in index

2019-04-18 Thread Jeff King
The on-disk format for the untracked-cache extension contains NUL-terminated filenames. We parse these from the mmap'd file using string functions like strlen(). This works fine in the normal case, but if we see a malformed or corrupted index, we might read off the end of our mmap. Instead, let's