Fix race condition in allocating obfsBuf

This commit is contained in:
Andy Wang 2020-12-23 17:42:54 +00:00
parent 5c5e9f8c14
commit 9108794362
No known key found for this signature in database
GPG Key ID: 181B49F9F38F3374
1 changed files with 2 additions and 0 deletions

View File

@ -174,9 +174,11 @@ func (s *Stream) Write(in []byte) (n int, err error) {
// ReadFrom continuously read data from r and send it off, until either r returns error or nothing has been read
// for readFromTimeout amount of time
func (s *Stream) ReadFrom(r io.Reader) (n int64, err error) {
s.writingM.Lock()
if s.obfsBuf == nil {
s.obfsBuf = make([]byte, s.session.StreamSendBufferSize)
}
s.writingM.Unlock()
for {
if s.readFromTimeout != 0 {
if rder, ok := r.(net.Conn); !ok {