summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMura Li <typeless@users.noreply.github.com>2017-03-31 16:42:23 +0800
committerBo-Yi Wu <appleboy.tw@gmail.com>2017-03-31 16:42:23 +0800
commit6a39250579f240721d5d8b2eca017fa94126dc9d (patch)
treee79ff0c539d46a1df46ddc9392be9db2a1afa146
parentfac7a6fecf266046dbd205811a9f907704729059 (diff)
downloadgitea-6a39250579f240721d5d8b2eca017fa94126dc9d.tar.gz
gitea-6a39250579f240721d5d8b2eca017fa94126dc9d.zip
Add length check for the return string (#1420)
* Add length check for the return string * Differentiate error paths and logging messages * Rectify error message
-rw-r--r--models/pull.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/models/pull.go b/models/pull.go
index 822822411a..ababe79dd4 100644
--- a/models/pull.go
+++ b/models/pull.go
@@ -507,7 +507,9 @@ func (pr *PullRequest) getMergeCommit() (*git.Commit, error) {
mergeCommit, stderr, err := process.GetManager().ExecDirEnv(-1, "", fmt.Sprintf("isMerged (git rev-list --ancestry-path --merges --reverse): %d", pr.BaseRepo.ID),
[]string{"GIT_INDEX_FILE=" + indexTmpPath, "GIT_DIR=" + pr.BaseRepo.RepoPath()},
"git", "rev-list", "--ancestry-path", "--merges", "--reverse", cmd)
-
+ if err == nil && len(mergeCommit) != 40 {
+ err = fmt.Errorf("unexpected length of output (got:%d bytes) '%s'", len(mergeCommit), mergeCommit)
+ }
if err != nil {
return nil, fmt.Errorf("git rev-list --ancestry-path --merges --reverse: %v %v", stderr, err)
}