summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2016-04-27 12:39:11 +0200
committerMichael Haggerty <mhagger@alum.mit.edu>2016-05-05 16:37:30 +0200
commit39950fef8bb45e944655e48393ee04c0b33211f5 (patch)
tree7b6f2d24230738960004df94fe835112bdceaf04 /refs.c
parent728af2832c3e58222965521682414adb9a80932b (diff)
downloadgit-39950fef8bb45e944655e48393ee04c0b33211f5.tar.gz
refname_is_safe(): use skip_prefix()
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/refs.c b/refs.c
index 87dc82f1d8..5789152743 100644
--- a/refs.c
+++ b/refs.c
@@ -120,17 +120,19 @@ int check_refname_format(const char *refname, int flags)
int refname_is_safe(const char *refname)
{
- if (starts_with(refname, "refs/")) {
+ const char *rest;
+
+ if (skip_prefix(refname, "refs/", &rest)) {
char *buf;
int result;
- buf = xmallocz(strlen(refname));
/*
* Does the refname try to escape refs/?
* For example: refs/foo/../bar is safe but refs/foo/../../bar
* is not.
*/
- result = !normalize_path_copy(buf, refname + strlen("refs/"));
+ buf = xmallocz(strlen(rest));
+ result = !normalize_path_copy(buf, rest);
free(buf);
return result;
}