Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions routers/repo/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,14 +364,23 @@ func serviceRPC(h serviceHandler, service string) {
}

if h.cfg.OnSucceed != nil {
input, err = ioutil.ReadAll(reqBody)
tmpfile, err := ioutil.TempFile("", "gogs")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hadn't found info about the permissions that TempFile would put on the file, I guess it should be checked

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if err != nil {
log.GitLogger.Error(2, "fail to read request body: %v", err)
log.GitLogger.Error(2, "fail to create temporary file: %v", err)
h.w.WriteHeader(http.StatusInternalServerError)
return
}
defer os.Remove(tmpfile.Name())
defer tmpfile.Close()

br = bytes.NewReader(input)
_, err = io.Copy(tmpfile, reqBody)
if err != nil {
log.GitLogger.Error(2, "fail to save request body: %v", err)
h.w.WriteHeader(http.StatusInternalServerError)
return
}

br = tmpfile
} else {
br = reqBody
}
Expand Down