Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
refname_is_safe(): use skip_prefix()
author
Michael Haggerty
<mhagger@alum.mit.edu>
Wed, 27 Apr 2016 10:39:11 +0000
(12:39 +0200)
committer
Michael Haggerty
<mhagger@alum.mit.edu>
Thu, 5 May 2016 14:37:30 +0000
(16:37 +0200)
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
refs.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
728af28
)
diff --git
a/refs.c
b/refs.c
index 87dc82f1d87d6c0969b97f94035233bec0bc3729..5789152743ffbf0ac0f9a0270e2d689349cf7682 100644
(file)
--- 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)
{
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;
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.
*/
/*
* 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;
}
free(buf);
return result;
}