summaryrefslogtreecommitdiff
path: root/src/refs.c
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2013-02-07 23:40:10 +0100
committernulltoken <emeric.fermas@gmail.com>2013-02-11 23:19:40 +0100
commit4d811c3b77158fdb7ee50b389c3aa8763482c61a (patch)
tree4e27913be9abefa36f91e2d6d6d63450ac916cbc /src/refs.c
parent624924e876b9e69ee613dfc38541da3ef0967d56 (diff)
downloadlibgit2-4d811c3b77158fdb7ee50b389c3aa8763482c61a.tar.gz
refs: No component of a refname can end with '.lock'
Diffstat (limited to 'src/refs.c')
-rw-r--r--src/refs.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/refs.c b/src/refs.c
index e75f51001..fd57ce8f7 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -1599,6 +1599,7 @@ static int ensure_segment_validity(const char *name)
{
const char *current = name;
char prev = '\0';
+ int lock_len = strlen(GIT_FILELOCK_EXTENSION);
if (*current == '.')
return -1; /* Refname starts with "." */
@@ -1619,6 +1620,11 @@ static int ensure_segment_validity(const char *name)
prev = *current;
}
+ /* A refname component can not end with ".lock" */
+ if (current - name >= lock_len &&
+ !git__strncmp(current - lock_len, GIT_FILELOCK_EXTENSION, lock_len))
+ return -1;
+
return (int)(current - name);
}
@@ -1714,10 +1720,6 @@ int git_reference__normalize_name(
if (current[segment_len - 1] == '/')
goto cleanup;
- /* A refname can not end with ".lock" */
- if (!git__suffixcmp(name, GIT_FILELOCK_EXTENSION))
- goto cleanup;
-
if ((segments_count == 1 ) && !(flags & GIT_REF_FORMAT_ALLOW_ONELEVEL))
goto cleanup;