diff options
| author | nulltoken <emeric.fermas@gmail.com> | 2011-03-03 19:43:11 +0200 |
|---|---|---|
| committer | Vicent Marti <tanoku@gmail.com> | 2011-03-03 20:23:51 +0200 |
| commit | 129007b423de2c421b4b87f306dcb509e5313caf (patch) | |
| tree | 964b5c353a87b90e593e8551dd8565072c996def | |
| parent | 65cc1f44e15b042049f4c29058768e6304fad60f (diff) | |
| download | libgit2-129007b423de2c421b4b87f306dcb509e5313caf.tar.gz | |
Fix refs renaming to prevent renaming with an invalid name
| -rw-r--r-- | src/refs.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/refs.c b/src/refs.c index 674839b8b..19f5406a4 100644 --- a/src/refs.c +++ b/src/refs.c @@ -1123,11 +1123,16 @@ int git_reference_rename(git_reference *ref, const char *new_name) { int error; char *old_name; - char old_path[GIT_PATH_MAX], new_path[GIT_PATH_MAX]; + char old_path[GIT_PATH_MAX], new_path[GIT_PATH_MAX], normalized_name[MAX_GITDIR_TREE_STRUCTURE_PATH_LENGTH]; git_reference *looked_up_ref; assert(ref); + /* Ensure the name is valid */ + error = normalize_name(normalized_name, new_name, ref->type & GIT_REF_OID); + if (error < GIT_SUCCESS) + return error; + /* Ensure we're not going to overwrite an existing reference */ error = git_repository_lookup_ref(&looked_up_ref, ref->owner, new_name); if (error == GIT_SUCCESS) |
