comparison netio.c @ 1346:78b7e0634117 fuzz

notsocket changes from afl branch
author Matt Johnston <matt@ucc.asn.au>
date Fri, 12 May 2017 22:14:49 +0800
parents 3b624ad2dc5e
children 3fdd8c5a0195
comparison
equal deleted inserted replaced
1313:0ed3d2bbf956 1346:78b7e0634117
483 socklen_t addrlen; 483 socklen_t addrlen;
484 484
485 if (local_host || local_port) { 485 if (local_host || local_port) {
486 addrlen = sizeof(addr); 486 addrlen = sizeof(addr);
487 if (getsockname(fd, (struct sockaddr*)&addr, &addrlen) < 0) { 487 if (getsockname(fd, (struct sockaddr*)&addr, &addrlen) < 0) {
488 dropbear_exit("Failed socket address: %s", strerror(errno)); 488 if (errno == ENOTSOCK) {
489 // FUZZ
490 if (local_host) {
491 *local_host = m_strdup("notsocket");
492 }
493 if (local_port) {
494 *local_port = m_strdup("999");
495 }
496 return;
497 } else {
498 dropbear_exit("Failed socket address: %s", strerror(errno));
499 }
489 } 500 }
490 getaddrstring(&addr, local_host, local_port, host_lookup); 501 getaddrstring(&addr, local_host, local_port, host_lookup);
491 } 502 }
492 if (remote_host || remote_port) { 503 if (remote_host || remote_port) {
493 addrlen = sizeof(addr); 504 addrlen = sizeof(addr);
494 if (getpeername(fd, (struct sockaddr*)&addr, &addrlen) < 0) { 505 if (getpeername(fd, (struct sockaddr*)&addr, &addrlen) < 0) {
495 dropbear_exit("Failed socket address: %s", strerror(errno)); 506 if (errno == ENOTSOCK) {
507 // FUZZ
508 if (remote_host) {
509 *remote_host = m_strdup("notsocket");
510 }
511 if (remote_port) {
512 *remote_port = m_strdup("999");
513 }
514 return;
515 } else {
516 dropbear_exit("Failed socket address: %s", strerror(errno));
517 }
496 } 518 }
497 getaddrstring(&addr, remote_host, remote_port, host_lookup); 519 getaddrstring(&addr, remote_host, remote_port, host_lookup);
498 } 520 }
499 } 521 }
500 522
544 * to exhibit that behaviour. */ 566 * to exhibit that behaviour. */
545 getaddrstring(addr, ret_host, ret_port, 0); 567 getaddrstring(addr, ret_host, ret_port, 0);
546 return; 568 return;
547 } else { 569 } else {
548 /* if we can't do a numeric lookup, something's gone terribly wrong */ 570 /* if we can't do a numeric lookup, something's gone terribly wrong */
571 if (ret == EAI_FAMILY) {
572 // FUZZ
573 // Fake it for non-socket input
574 if (ret_host) {
575 *ret_host = m_strdup("0.0.0.0");
576 }
577 if (ret_port)
578 {
579 *ret_port = m_strdup("999");
580 }
581 return;
582 }
549 dropbear_exit("Failed lookup: %s", gai_strerror(ret)); 583 dropbear_exit("Failed lookup: %s", gai_strerror(ret));
550 } 584 }
551 } 585 }
552 586
553 if (ret_host) { 587 if (ret_host) {