comparison fuzz/fuzz-common.c @ 1786:a3b39df57c8b

fuzz: add an always-failing dropbear_listen() replacement
author Matt Johnston <matt@ucc.asn.au>
date Sun, 06 Dec 2020 21:54:01 +0800
parents 9026f976eee8
children 8df3d6aa5f23
comparison
equal deleted inserted replaced
1785:9026f976eee8 1786:a3b39df57c8b
253 cb(DROPBEAR_FAILURE, -1, cb_data, "errorstring"); 253 cb(DROPBEAR_FAILURE, -1, cb_data, "errorstring");
254 } 254 }
255 return NULL; 255 return NULL;
256 } 256 }
257 257
258 /* Fake dropbear_listen, always returns failure for now.
259 TODO make it sometimes return success with wrapfd_new_dummy() sockets.
260 Making the listeners fake a new incoming connection will be harder. */
261 /* Listen on address:port.
262 * Special cases are address of "" listening on everything,
263 * and address of NULL listening on localhost only.
264 * Returns the number of sockets bound on success, or -1 on failure. On
265 * failure, if errstring wasn't NULL, it'll be a newly malloced error
266 * string.*/
267 int fuzz_dropbear_listen(const char* UNUSED(address), const char* UNUSED(port),
268 int *UNUSED(socks), unsigned int UNUSED(sockcount), char **errstring, int *UNUSED(maxfd)) {
269 if (errstring) {
270 *errstring = m_strdup("fuzzing can't listen (yet)");
271 }
272 return -1;
273 }
274
258 int fuzz_run_server(const uint8_t *Data, size_t Size, int skip_kexmaths, int postauth) { 275 int fuzz_run_server(const uint8_t *Data, size_t Size, int skip_kexmaths, int postauth) {
259 static int once = 0; 276 static int once = 0;
260 if (!once) { 277 if (!once) {
261 fuzz_svr_setup(); 278 fuzz_svr_setup();
262 fuzz.skip_kexmaths = skip_kexmaths; 279 fuzz.skip_kexmaths = skip_kexmaths;