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
182b28d9
Commit
182b28d9
authored
Sep 30, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Comments, better function name
parent
a00a3460
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
6 deletions
+12
-6
internal/git/git-http.go
internal/git/git-http.go
+7
-2
internal/git/git-http_test.go
internal/git/git-http_test.go
+2
-3
internal/git/pktline.go
internal/git/pktline.go
+3
-1
No files found.
internal/git/git-http.go
View file @
182b28d9
...
...
@@ -20,6 +20,11 @@ import (
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
)
// In the request body for POST /git-upload-pack, the client is telling
// git-upload-pack which objects is wants and which objects it already
// has. Each 'want' or 'have' is about 30 bytes. Limiting the total
// git-upload-pack request body size at 1000000 means that we allow for
// about 33000 want/have messages.
const
uploadPackRequestLimit
=
1000000
func
GetInfoRefs
(
a
*
api
.
API
)
http
.
Handler
{
...
...
@@ -117,7 +122,7 @@ func handlePostRPC(w http.ResponseWriter, r *http.Request, a *api.Response) {
}
if
action
==
"git-upload-pack"
{
buffer
,
err
:=
buffer
PostBody
(
r
.
Body
)
buffer
,
err
:=
buffer
UploadPackRequest
(
r
.
Body
)
if
err
!=
nil
{
helper
.
Fail500
(
w
,
r
,
&
copyError
{
fmt
.
Errorf
(
"handlePostRPC: buffer git-upload-pack body: %v"
)})
return
...
...
@@ -195,7 +200,7 @@ func subCommand(rpc string) string {
return
strings
.
TrimPrefix
(
rpc
,
"git-"
)
}
func
buffer
PostBody
(
body
io
.
Reader
)
(
*
bytes
.
Buffer
,
error
)
{
func
buffer
UploadPackRequest
(
body
io
.
Reader
)
(
*
bytes
.
Buffer
,
error
)
{
buffer
:=
&
bytes
.
Buffer
{}
n
,
err
:=
io
.
Copy
(
buffer
,
&
io
.
LimitedReader
{
R
:
body
,
N
:
uploadPackRequestLimit
})
if
err
==
nil
&&
n
==
uploadPackRequestLimit
{
...
...
internal/git/git-http_test.go
View file @
182b28d9
...
...
@@ -5,12 +5,11 @@ import (
"testing"
)
func
TestB
ufferPostBody
Limiting
(
t
*
testing
.
T
)
{
_
,
err
:=
buffer
PostBody
(
bytes
.
NewReader
(
make
([]
byte
,
2000000
)))
func
TestB
bufferUploadPackRequest
Limiting
(
t
*
testing
.
T
)
{
_
,
err
:=
buffer
UploadPackRequest
(
bytes
.
NewReader
(
make
([]
byte
,
2000000
)))
t
.
Log
(
err
)
if
err
==
nil
{
t
.
Fatalf
(
"expected an error, received nil"
)
}
}
internal/git/pktline.go
View file @
182b28d9
...
...
@@ -43,7 +43,7 @@ func pktLineSplitter(data []byte, atEOF bool) (advance int, token []byte, err er
if
bytes
.
HasPrefix
(
data
,
[]
byte
(
"0000"
))
{
// special case: "0000" terminator packet: return empty token
return
4
,
data
[
4
:
4
],
nil
return
4
,
data
[
:
0
],
nil
}
// We have at least 4 bytes available so we can decode the 4-hex digit
...
...
@@ -53,6 +53,7 @@ func pktLineSplitter(data []byte, atEOF bool) (advance int, token []byte, err er
return
0
,
nil
,
fmt
.
Errorf
(
"pktLineSplitter: decode length: %v"
,
err
)
}
// Cast is safe because we requested an int-size number from strconv.ParseInt
pktLength
:=
int
(
pktLength64
)
if
pktLength
<
0
{
...
...
@@ -66,5 +67,6 @@ func pktLineSplitter(data []byte, atEOF bool) (advance int, token []byte, err er
return
0
,
nil
,
nil
// want more data
}
// return "pkt" token without length prefix
return
pktLength
,
data
[
4
:
pktLength
],
nil
}
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