Coverage Report

Created: 2024-05-20 06:23

/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
9.64k
int32_t DummyPrSocket::Read(PRFileDesc *f, void *data, int32_t len) {
15
9.64k
  assert(data && len > 0);
16
17
9.64k
  int32_t amount = std::min(len, static_cast<int32_t>(len_));
18
9.64k
  memcpy(data, buf_, amount);
19
20
9.64k
  buf_ += amount;
21
9.64k
  len_ -= amount;
22
23
9.64k
  return amount;
24
9.64k
}
25
26
17.8k
int32_t DummyPrSocket::Write(PRFileDesc *f, const void *buf, int32_t length) {
27
17.8k
  return length;
28
17.8k
}
29
30
int32_t DummyPrSocket::Recv(PRFileDesc *f, void *buf, int32_t buflen,
31
9.64k
                            int32_t flags, PRIntervalTime to) {
32
9.64k
  assert(flags == 0);
33
9.64k
  return Read(f, buf, buflen);
34
9.64k
}