diff --git a/path.c b/path.c index e50d2befcf..1ca2cf9a28 100644 --- a/path.c +++ b/path.c @@ -661,6 +661,10 @@ int validate_headref(const char *path) len = read_in_full(fd, buffer, sizeof(buffer)-1); close(fd); + if (len < 0) + return -1; + buffer[len] = '\0'; + /* * Is it a symbolic ref? */