Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(392)

Side by Side Diff: remoting/host/gnubby_socket.cc

Issue 216693005: Fix memory overwrite when sending error code on socket (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/host/gnubby_socket.h" 5 #include "remoting/host/gnubby_socket.h"
6 6
7 #include "base/macros.h"
7 #include "base/timer/timer.h" 8 #include "base/timer/timer.h"
8 #include "net/socket/stream_listen_socket.h" 9 #include "net/socket/stream_listen_socket.h"
9 10
10 namespace remoting { 11 namespace remoting {
11 12
12 namespace { 13 namespace {
13 14
14 const size_t kRequestSizeBytes = 4; 15 const size_t kRequestSizeBytes = 4;
15 const size_t kMaxRequestLength = 16384; 16 const size_t kMaxRequestLength = 16384;
16 const unsigned int kRequestTimeoutSeconds = 60; 17 const unsigned int kRequestTimeoutSeconds = 60;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 DCHECK(CalledOnValidThread()); 69 DCHECK(CalledOnValidThread());
69 70
70 socket_->Send(GetResponseLengthAsBytes(response_data)); 71 socket_->Send(GetResponseLengthAsBytes(response_data));
71 socket_->Send(response_data); 72 socket_->Send(response_data);
72 ResetTimer(); 73 ResetTimer();
73 } 74 }
74 75
75 void GnubbySocket::SendSshError() { 76 void GnubbySocket::SendSshError() {
76 DCHECK(CalledOnValidThread()); 77 DCHECK(CalledOnValidThread());
77 78
78 SendResponse(kSshError); 79 SendResponse(std::string(kSshError, arraysize(kSshError)));
79 } 80 }
80 81
81 bool GnubbySocket::IsSocket(net::StreamListenSocket* socket) const { 82 bool GnubbySocket::IsSocket(net::StreamListenSocket* socket) const {
82 return socket == socket_.get(); 83 return socket == socket_.get();
83 } 84 }
84 85
85 void GnubbySocket::SetTimerForTesting(scoped_ptr<base::Timer> timer) { 86 void GnubbySocket::SetTimerForTesting(scoped_ptr<base::Timer> timer) {
86 timer->Start(FROM_HERE, timer_->GetCurrentDelay(), timer_->user_task()); 87 timer->Start(FROM_HERE, timer_->GetCurrentDelay(), timer_->user_task());
87 timer_ = timer.Pass(); 88 timer_ = timer.Pass();
88 } 89 }
(...skipping 18 matching lines...) Expand all
107 108
108 return response_len; 109 return response_len;
109 } 110 }
110 111
111 void GnubbySocket::ResetTimer() { 112 void GnubbySocket::ResetTimer() {
112 if (timer_->IsRunning()) 113 if (timer_->IsRunning())
113 timer_->Reset(); 114 timer_->Reset();
114 } 115 }
115 116
116 } // namespace remoting 117 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698