/src/nss/fuzz/tls_socket.cc
| Line | Count | Source | 
| 1 |  | /* This Source Code Form is subject to the terms of the Mozilla Public | 
| 2 |  |  * License, v. 2.0. If a copy of the MPL was not distributed with this | 
| 3 |  |  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 
| 4 |  |  | 
| 5 |  | #include <assert.h> | 
| 6 |  | #include <string.h> | 
| 7 |  | #include <algorithm> | 
| 8 |  |  | 
| 9 |  | #include "prerror.h" | 
| 10 |  | #include "prio.h" | 
| 11 |  |  | 
| 12 |  | #include "tls_socket.h" | 
| 13 |  |  | 
| 14 | 55.3k | int32_t DummyPrSocket::Read(PRFileDesc *f, void *data, int32_t len) { | 
| 15 | 55.3k |   assert(data && len > 0); | 
| 16 |  |  | 
| 17 | 55.3k |   int32_t amount = std::min(len, static_cast<int32_t>(len_)); | 
| 18 | 55.3k |   memcpy(data, buf_, amount); | 
| 19 |  |  | 
| 20 | 55.3k |   buf_ += amount; | 
| 21 | 55.3k |   len_ -= amount; | 
| 22 |  |  | 
| 23 | 55.3k |   return amount; | 
| 24 | 55.3k | } | 
| 25 |  |  | 
| 26 | 11.1k | int32_t DummyPrSocket::Write(PRFileDesc *f, const void *buf, int32_t length) { | 
| 27 | 11.1k |   return length; | 
| 28 | 11.1k | } | 
| 29 |  |  | 
| 30 |  | int32_t DummyPrSocket::Recv(PRFileDesc *f, void *buf, int32_t buflen, | 
| 31 | 55.3k |                             int32_t flags, PRIntervalTime to) { | 
| 32 | 55.3k |   assert(flags == 0); | 
| 33 | 55.3k |   return Read(f, buf, buflen); | 
| 34 | 55.3k | } |