Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Anti-censorship
Pluggable Transports
Snowflake
Commits
ce3101d0
Commit
ce3101d0
authored
May 10, 2019
by
Cecylia Bocovich
Browse files
Guard against large reads
This is a fix for
#26348
parent
5380aaca
Changes
3
Hide whitespace changes
Inline
Side-by-side
broker/broker.go
View file @
ce3101d0
...
...
@@ -136,7 +136,7 @@ For snowflake proxies to request a client from the Broker.
*/
func
proxyPolls
(
ctx
*
BrokerContext
,
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
id
:=
r
.
Header
.
Get
(
"X-Session-ID"
)
body
,
err
:=
ioutil
.
ReadAll
(
r
.
Body
)
body
,
err
:=
ioutil
.
ReadAll
(
http
.
MaxBytesReader
(
w
,
r
.
Body
,
100000
)
)
if
nil
!=
err
{
log
.
Println
(
"Invalid data."
)
w
.
WriteHeader
(
http
.
StatusBadRequest
)
...
...
@@ -166,7 +166,7 @@ the HTTP response back to the client.
*/
func
clientOffers
(
ctx
*
BrokerContext
,
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
startTime
:=
time
.
Now
()
offer
,
err
:=
ioutil
.
ReadAll
(
r
.
Body
)
offer
,
err
:=
ioutil
.
ReadAll
(
http
.
MaxBytesReader
(
w
,
r
.
Body
,
100000
)
)
if
nil
!=
err
{
log
.
Println
(
"Invalid data."
)
w
.
WriteHeader
(
http
.
StatusBadRequest
)
...
...
@@ -213,7 +213,7 @@ func proxyAnswers(ctx *BrokerContext, w http.ResponseWriter, r *http.Request) {
w
.
WriteHeader
(
http
.
StatusGone
)
return
}
body
,
err
:=
ioutil
.
ReadAll
(
r
.
Body
)
body
,
err
:=
ioutil
.
ReadAll
(
http
.
MaxBytesReader
(
w
,
r
.
Body
,
100000
)
)
if
nil
!=
err
||
nil
==
body
||
len
(
body
)
<=
0
{
log
.
Println
(
"Invalid data."
)
w
.
WriteHeader
(
http
.
StatusBadRequest
)
...
...
client/lib/rendezvous.go
View file @
ce3101d0
...
...
@@ -91,7 +91,7 @@ func (bc *BrokerChannel) Negotiate(offer *webrtc.SessionDescription) (
switch
resp
.
StatusCode
{
case
http
.
StatusOK
:
body
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
body
,
err
:=
ioutil
.
ReadAll
(
http
.
MaxBytesReader
(
nil
,
resp
.
Body
,
100000
)
)
if
nil
!=
err
{
return
nil
,
err
}
...
...
proxy-go/snowflake.go
View file @
ce3101d0
...
...
@@ -162,7 +162,7 @@ func pollOffer(sid string) *webrtc.SessionDescription {
if
resp
.
StatusCode
!=
http
.
StatusOK
{
log
.
Printf
(
"broker returns: %d"
,
resp
.
StatusCode
)
}
else
{
body
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
body
,
err
:=
ioutil
.
ReadAll
(
http
.
MaxBytesReader
(
nil
,
resp
.
Body
,
100000
)
)
if
err
!=
nil
{
log
.
Printf
(
"error reading broker response: %s"
,
err
)
}
else
{
...
...
Write
Preview
Supports
Markdown
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