Code

git config: codestyle cleanups
[git.git] / path.c
diff --git a/path.c b/path.c
index eb24017535f944a2c5dbc46663c02937cff69cd3..108d9e9599d059a06fd0621188f45a716346ca07 100644 (file)
--- a/path.c
+++ b/path.c
@@ -41,7 +41,7 @@ char *mksnpath(char *buf, size_t n, const char *fmt, ...)
        len = vsnprintf(buf, n, fmt, args);
        va_end(args);
        if (len >= n) {
-               snprintf(buf, n, bad_path);
+               strlcpy(buf, bad_path, n);
                return buf;
        }
        return cleanup_path(buf);
@@ -63,7 +63,7 @@ static char *git_vsnpath(char *buf, size_t n, const char *fmt, va_list args)
                goto bad;
        return cleanup_path(buf);
 bad:
-       snprintf(buf, n, bad_path);
+       strlcpy(buf, bad_path, n);
        return buf;
 }
 
@@ -154,7 +154,7 @@ int validate_headref(const char *path)
        /* Make sure it is a "refs/.." symlink */
        if (S_ISLNK(st.st_mode)) {
                len = readlink(path, buffer, sizeof(buffer)-1);
-               if (len >= 5 && !memcmp("refs/", buffer, 5))
+               if (len >= 11 && !memcmp("refs/heads/", buffer, 11))
                        return 0;
                return -1;
        }
@@ -178,7 +178,7 @@ int validate_headref(const char *path)
                len -= 4;
                while (len && isspace(*buf))
                        buf++, len--;
-               if (len >= 5 && !memcmp("refs/", buf, 5))
+               if (len >= 11 && !memcmp("refs/heads/", buf, 11))
                        return 0;
        }