| 139 | } |
| 140 | |
| 141 | int FuzzedSock::Connect(const sockaddr*, socklen_t) const |
| 142 | { |
| 143 | // Have a permanent error at connect_errnos[0] because when the fuzzed data is exhausted |
| 144 | // SetFuzzedErrNo() will always return the first element and we want to avoid Connect() |
| 145 | // returning -1 and setting errno to EAGAIN repeatedly. |
| 146 | constexpr std::array connect_errnos{ |
| 147 | ECONNREFUSED, |
| 148 | EAGAIN, |
| 149 | ECONNRESET, |
| 150 | EHOSTUNREACH, |
| 151 | EINPROGRESS, |
| 152 | EINTR, |
| 153 | ENETUNREACH, |
| 154 | ETIMEDOUT, |
| 155 | }; |
| 156 | if (m_fuzzed_data_provider.ConsumeBool()) { |
| 157 | SetFuzzedErrNo(m_fuzzed_data_provider, connect_errnos); |
| 158 | return -1; |
| 159 | } |
| 160 | return 0; |
| 161 | } |
| 162 | |
| 163 | std::unique_ptr<Sock> FuzzedSock::Accept(sockaddr* addr, socklen_t* addr_len) const |
| 164 | { |
no test coverage detected