зеркало из https://github.com/microsoft/git.git
refname_is_safe(): use skip_prefix()
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
This commit is contained in:
Родитель
728af2832c
Коммит
39950fef8b
8
refs.c
8
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;
|
char *buf;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
buf = xmallocz(strlen(refname));
|
|
||||||
/*
|
/*
|
||||||
* Does the refname try to escape refs/?
|
* Does the refname try to escape refs/?
|
||||||
* For example: refs/foo/../bar is safe but refs/foo/../../bar
|
* For example: refs/foo/../bar is safe but refs/foo/../../bar
|
||||||
* is not.
|
* is not.
|
||||||
*/
|
*/
|
||||||
result = !normalize_path_copy(buf, refname + strlen("refs/"));
|
buf = xmallocz(strlen(rest));
|
||||||
|
result = !normalize_path_copy(buf, rest);
|
||||||
free(buf);
|
free(buf);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче