Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-workhorse
Commits
18334f75
Commit
18334f75
authored
Jan 19, 2017
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent pipe leaks
parent
9a775998
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
internal/git/git-http.go
internal/git/git-http.go
+13
-0
No files found.
internal/git/git-http.go
View file @
18334f75
...
@@ -71,6 +71,19 @@ func repoPreAuthorizeHandler(myAPI *api.API, handleFunc api.HandleFunc) http.Han
...
@@ -71,6 +71,19 @@ func repoPreAuthorizeHandler(myAPI *api.API, handleFunc api.HandleFunc) http.Han
}
}
func
setupGitCommand
(
action
string
,
a
*
api
.
Response
,
w
*
GitHttpResponseWriter
,
r
*
http
.
Request
)
(
cmd
*
exec
.
Cmd
,
stdin
io
.
WriteCloser
,
stdout
io
.
ReadCloser
,
err
error
)
{
func
setupGitCommand
(
action
string
,
a
*
api
.
Response
,
w
*
GitHttpResponseWriter
,
r
*
http
.
Request
)
(
cmd
*
exec
.
Cmd
,
stdin
io
.
WriteCloser
,
stdout
io
.
ReadCloser
,
err
error
)
{
// Don't leak pipes when we return early after an error
defer
func
()
{
if
err
==
nil
{
return
}
if
stdin
!=
nil
{
stdin
.
Close
()
}
if
stdout
!=
nil
{
stdout
.
Close
()
}
}()
// Prepare our Git subprocess
// Prepare our Git subprocess
cmd
=
gitCommand
(
a
.
GL_ID
,
"git"
,
subCommand
(
action
),
"--stateless-rpc"
,
a
.
RepoPath
)
cmd
=
gitCommand
(
a
.
GL_ID
,
"git"
,
subCommand
(
action
),
"--stateless-rpc"
,
a
.
RepoPath
)
stdout
,
err
=
cmd
.
StdoutPipe
()
stdout
,
err
=
cmd
.
StdoutPipe
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment