{
const char *current = name;
char prev = '\0';
+ int lock_len = strlen(GIT_FILELOCK_EXTENSION);
if (*current == '.')
return -1; /* Refname starts with "." */
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);
}
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;
cl_assert_equal_i(false, git_reference_is_valid_name("/stupid/name/master"));
cl_assert_equal_i(false, git_reference_is_valid_name("/"));
cl_assert_equal_i(false, git_reference_is_valid_name(""));
+ cl_assert_equal_i(false, git_reference_is_valid_name("refs/heads/sub.lock/webmatrix"));
}
void test_refs_isvalidname__wont_hopefully_choke_on_valid_formats(void)