]> git.ipfire.org Git - thirdparty/git.git/blobdiff - path.c
validate_headref: NUL-terminate HEAD buffer
[thirdparty/git.git] / path.c
diff --git a/path.c b/path.c
index e485f9f93181778de3acfe3cd4b6811ec82c7940..1ca2cf9a289731174c8e7d4ff0e790e0be1d9f18 100644 (file)
--- 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?
         */
@@ -1321,6 +1325,11 @@ int is_ntfs_dotgit(const char *name)
                }
 }
 
+int looks_like_command_line_option(const char *str)
+{
+       return str && str[0] == '-';
+}
+
 char *xdg_config_home(const char *filename)
 {
        const char *home, *config_home;