While looking at read_in_full() callers for a nearby patch series, I noticed this fairly harmless bug. The first patch fixes it, and the other two do some cleanups on top. I'm tempted to say the whole thing ought to just use a strbuf. We typically only call this function once per program, and git HEAD files are small enough not to worry about. On the other hand, the point of the function is to see if this is in fact a git repository. So in the rare case that we see a file named ".git/HEAD" that's actually a 2GB video file, we'd prefer to find out after reading only 256 bytes, not the whole thing. [1/3]: validate_headref: NUL-terminate HEAD buffer [2/3]: validate_headref: use skip_prefix for symref parsing [3/3]: validate_headref: use get_oid_hex for detached HEADs path.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) -Peff