mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 13:11:28 +00:00
Use ncat_assert in place of assert everywhere.
This commit is contained in:
@@ -89,7 +89,6 @@
|
|||||||
|
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "base64.h"
|
#include "base64.h"
|
||||||
@@ -528,7 +527,7 @@ static const char *skip_crlf(const char *s)
|
|||||||
else if (*s == '\r' && *(s + 1) == '\n')
|
else if (*s == '\r' && *(s + 1) == '\n')
|
||||||
return s + 2;
|
return s + 2;
|
||||||
|
|
||||||
assert(0);
|
ncat_assert(0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -102,7 +102,6 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#endif
|
#endif
|
||||||
#include <assert.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -164,7 +163,7 @@ static int verify_callback(int ok, X509_STORE_CTX *store)
|
|||||||
X509_NAME_print_ex_fp(stderr, X509_get_issuer_name(cert), 0, XN_FLAG_COMPAT);
|
X509_NAME_print_ex_fp(stderr, X509_get_issuer_name(cert), 0, XN_FLAG_COMPAT);
|
||||||
loguser_noprefix("\n");
|
loguser_noprefix("\n");
|
||||||
|
|
||||||
assert(ssl_cert_fp_str_sha1(cert, digest_buf, sizeof(digest_buf)) != NULL);
|
ncat_assert(ssl_cert_fp_str_sha1(cert, digest_buf, sizeof(digest_buf)) != NULL);
|
||||||
loguser("SHA-1 fingerprint: %s\n", digest_buf);
|
loguser("SHA-1 fingerprint: %s\n", digest_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,7 +226,7 @@ static void connect_report(nsock_iod nsi)
|
|||||||
loguser("SSL connection to %s:%hu.", inet_socktop(&peer), nsi_peerport(nsi));
|
loguser("SSL connection to %s:%hu.", inet_socktop(&peer), nsi_peerport(nsi));
|
||||||
|
|
||||||
cert = SSL_get_peer_certificate((SSL *) nsi_getssl(nsi));
|
cert = SSL_get_peer_certificate((SSL *) nsi_getssl(nsi));
|
||||||
assert(cert != NULL);
|
ncat_assert(cert != NULL);
|
||||||
|
|
||||||
subject = X509_get_subject_name(cert);
|
subject = X509_get_subject_name(cert);
|
||||||
if (subject != NULL) {
|
if (subject != NULL) {
|
||||||
@@ -241,7 +240,7 @@ static void connect_report(nsock_iod nsi)
|
|||||||
|
|
||||||
loguser_noprefix("\n");
|
loguser_noprefix("\n");
|
||||||
|
|
||||||
assert(ssl_cert_fp_str_sha1(cert, digest_buf, sizeof(digest_buf)) != NULL);
|
ncat_assert(ssl_cert_fp_str_sha1(cert, digest_buf, sizeof(digest_buf)) != NULL);
|
||||||
loguser("SHA-1 fingerprint: %s\n", digest_buf);
|
loguser("SHA-1 fingerprint: %s\n", digest_buf);
|
||||||
} else {
|
} else {
|
||||||
#if HAVE_SYS_UN_H
|
#if HAVE_SYS_UN_H
|
||||||
@@ -706,7 +705,7 @@ static void connect_handler(nsock_pool nsp, nsock_event evt, void *data)
|
|||||||
enum nse_status status = nse_status(evt);
|
enum nse_status status = nse_status(evt);
|
||||||
enum nse_type type = nse_type(evt);
|
enum nse_type type = nse_type(evt);
|
||||||
|
|
||||||
assert(type == NSE_TYPE_CONNECT || type == NSE_TYPE_CONNECT_SSL);
|
ncat_assert(type == NSE_TYPE_CONNECT || type == NSE_TYPE_CONNECT_SSL);
|
||||||
|
|
||||||
if (status == NSE_STATUS_ERROR) {
|
if (status == NSE_STATUS_ERROR) {
|
||||||
loguser("%s.\n", socket_strerror(nse_errorcode(evt)));
|
loguser("%s.\n", socket_strerror(nse_errorcode(evt)));
|
||||||
@@ -715,7 +714,7 @@ static void connect_handler(nsock_pool nsp, nsock_event evt, void *data)
|
|||||||
loguser("%s.\n", socket_strerror(ETIMEDOUT));
|
loguser("%s.\n", socket_strerror(ETIMEDOUT));
|
||||||
exit(1);
|
exit(1);
|
||||||
} else {
|
} else {
|
||||||
assert(status == NSE_STATUS_SUCCESS);
|
ncat_assert(status == NSE_STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_OPENSSL
|
#ifdef HAVE_OPENSSL
|
||||||
@@ -779,7 +778,7 @@ static void read_stdin_handler(nsock_pool nsp, nsock_event evt, void *data)
|
|||||||
char *buf, *tmp = NULL;
|
char *buf, *tmp = NULL;
|
||||||
int nbytes;
|
int nbytes;
|
||||||
|
|
||||||
assert(type == NSE_TYPE_READ);
|
ncat_assert(type == NSE_TYPE_READ);
|
||||||
|
|
||||||
if (status == NSE_STATUS_EOF) {
|
if (status == NSE_STATUS_EOF) {
|
||||||
if (o.sendonly) {
|
if (o.sendonly) {
|
||||||
@@ -798,7 +797,7 @@ static void read_stdin_handler(nsock_pool nsp, nsock_event evt, void *data)
|
|||||||
} else if (status == NSE_STATUS_CANCELLED || status == NSE_STATUS_KILL) {
|
} else if (status == NSE_STATUS_CANCELLED || status == NSE_STATUS_KILL) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
assert(status == NSE_STATUS_SUCCESS);
|
ncat_assert(status == NSE_STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = nse_readbuf(evt, &nbytes);
|
buf = nse_readbuf(evt, &nbytes);
|
||||||
@@ -828,7 +827,7 @@ static void read_socket_handler(nsock_pool nsp, nsock_event evt, void *data)
|
|||||||
char *buf;
|
char *buf;
|
||||||
int nbytes;
|
int nbytes;
|
||||||
|
|
||||||
assert(type == NSE_TYPE_READ);
|
ncat_assert(type == NSE_TYPE_READ);
|
||||||
|
|
||||||
if (status == NSE_STATUS_EOF) {
|
if (status == NSE_STATUS_EOF) {
|
||||||
nsock_loop_quit(nsp);
|
nsock_loop_quit(nsp);
|
||||||
@@ -842,7 +841,7 @@ static void read_socket_handler(nsock_pool nsp, nsock_event evt, void *data)
|
|||||||
} else if (status == NSE_STATUS_CANCELLED || status == NSE_STATUS_KILL) {
|
} else if (status == NSE_STATUS_CANCELLED || status == NSE_STATUS_KILL) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
assert(status == NSE_STATUS_SUCCESS);
|
ncat_assert(status == NSE_STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = nse_readbuf(evt, &nbytes);
|
buf = nse_readbuf(evt, &nbytes);
|
||||||
@@ -867,7 +866,7 @@ static void write_socket_handler(nsock_pool nsp, nsock_event evt, void *data)
|
|||||||
enum nse_status status = nse_status(evt);
|
enum nse_status status = nse_status(evt);
|
||||||
enum nse_type type = nse_type(evt);
|
enum nse_type type = nse_type(evt);
|
||||||
|
|
||||||
assert(type == NSE_TYPE_WRITE);
|
ncat_assert(type == NSE_TYPE_WRITE);
|
||||||
|
|
||||||
if (status == NSE_STATUS_ERROR) {
|
if (status == NSE_STATUS_ERROR) {
|
||||||
loguser("%s.\n", socket_strerror(nse_errorcode(evt)));
|
loguser("%s.\n", socket_strerror(nse_errorcode(evt)));
|
||||||
@@ -878,7 +877,7 @@ static void write_socket_handler(nsock_pool nsp, nsock_event evt, void *data)
|
|||||||
} else if (status == NSE_STATUS_CANCELLED || status == NSE_STATUS_KILL) {
|
} else if (status == NSE_STATUS_CANCELLED || status == NSE_STATUS_KILL) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
assert(status == NSE_STATUS_SUCCESS);
|
ncat_assert(status == NSE_STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The write to the socket was successful. Allow reading more from stdin
|
/* The write to the socket was successful. Allow reading more from stdin
|
||||||
@@ -891,12 +890,12 @@ static void idle_timer_handler(nsock_pool nsp, nsock_event evt, void *data)
|
|||||||
enum nse_status status = nse_status(evt);
|
enum nse_status status = nse_status(evt);
|
||||||
enum nse_type type = nse_type(evt);
|
enum nse_type type = nse_type(evt);
|
||||||
|
|
||||||
assert(type == NSE_TYPE_TIMER);
|
ncat_assert(type == NSE_TYPE_TIMER);
|
||||||
|
|
||||||
if (status == NSE_STATUS_CANCELLED || status == NSE_STATUS_KILL)
|
if (status == NSE_STATUS_CANCELLED || status == NSE_STATUS_KILL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
assert(status == NSE_STATUS_SUCCESS);
|
ncat_assert(status == NSE_STATUS_SUCCESS);
|
||||||
|
|
||||||
loguser("Idle timeout expired (%d ms).\n", o.idletimeout);
|
loguser("Idle timeout expired (%d ms).\n", o.idletimeout);
|
||||||
|
|
||||||
|
|||||||
@@ -107,7 +107,6 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
/* Only two for now because we might have to listen on IPV4 and IPV6 */
|
/* Only two for now because we might have to listen on IPV4 and IPV6 */
|
||||||
union sockaddr_u listenaddrs[NUM_LISTEN_ADDRS];
|
union sockaddr_u listenaddrs[NUM_LISTEN_ADDRS];
|
||||||
@@ -191,9 +190,9 @@ static int resolve_internal(const char *hostname, unsigned short port,
|
|||||||
char portbuf[16];
|
char portbuf[16];
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
assert(hostname);
|
ncat_assert(hostname != NULL);
|
||||||
assert(ss);
|
ncat_assert(ss != NULL);
|
||||||
assert(sslen);
|
ncat_assert(sslen != NULL);
|
||||||
|
|
||||||
memset(&hints, 0, sizeof(hints));
|
memset(&hints, 0, sizeof(hints));
|
||||||
hints.ai_family = af;
|
hints.ai_family = af;
|
||||||
@@ -202,14 +201,14 @@ static int resolve_internal(const char *hostname, unsigned short port,
|
|||||||
|
|
||||||
/* Make the port number a string to give to getaddrinfo. */
|
/* Make the port number a string to give to getaddrinfo. */
|
||||||
rc = Snprintf(portbuf, sizeof(portbuf), "%hu", port);
|
rc = Snprintf(portbuf, sizeof(portbuf), "%hu", port);
|
||||||
assert(rc >= 0 && (size_t) rc < sizeof(portbuf));
|
ncat_assert(rc >= 0 && (size_t) rc < sizeof(portbuf));
|
||||||
|
|
||||||
rc = getaddrinfo(hostname, portbuf, &hints, &result);
|
rc = getaddrinfo(hostname, portbuf, &hints, &result);
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
return rc;
|
return rc;
|
||||||
if (result == NULL)
|
if (result == NULL)
|
||||||
return EAI_NONAME;
|
return EAI_NONAME;
|
||||||
assert(result->ai_addrlen > 0 && result->ai_addrlen <= (int) sizeof(struct sockaddr_storage));
|
ncat_assert(result->ai_addrlen > 0 && result->ai_addrlen <= (int) sizeof(struct sockaddr_storage));
|
||||||
*sslen = result->ai_addrlen;
|
*sslen = result->ai_addrlen;
|
||||||
memcpy(ss, result->ai_addr, *sslen);
|
memcpy(ss, result->ai_addr, *sslen);
|
||||||
freeaddrinfo(result);
|
freeaddrinfo(result);
|
||||||
|
|||||||
@@ -89,8 +89,6 @@
|
|||||||
|
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include "ncat.h"
|
#include "ncat.h"
|
||||||
|
|
||||||
/* This structure holds information about a subprocess with redirected input
|
/* This structure holds information about a subprocess with redirected input
|
||||||
@@ -186,11 +184,11 @@ extern void set_pseudo_sigchld_handler(void (*handler)(void))
|
|||||||
{
|
{
|
||||||
if (pseudo_sigchld_mutex == NULL) {
|
if (pseudo_sigchld_mutex == NULL) {
|
||||||
pseudo_sigchld_mutex = CreateMutex(NULL, FALSE, NULL);
|
pseudo_sigchld_mutex = CreateMutex(NULL, FALSE, NULL);
|
||||||
assert(pseudo_sigchld_mutex != NULL);
|
ncat_assert(pseudo_sigchld_mutex != NULL);
|
||||||
}
|
}
|
||||||
assert(WaitForSingleObject(pseudo_sigchld_mutex, INFINITE) == WAIT_OBJECT_0);
|
ncat_assert(WaitForSingleObject(pseudo_sigchld_mutex, INFINITE) == WAIT_OBJECT_0);
|
||||||
pseudo_sigchld_handler = handler;
|
pseudo_sigchld_handler = handler;
|
||||||
assert(ReleaseMutex(pseudo_sigchld_mutex) != 0);
|
ncat_assert(ReleaseMutex(pseudo_sigchld_mutex) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Run a command and redirect its input and output handles to a pair of
|
/* Run a command and redirect its input and output handles to a pair of
|
||||||
@@ -450,7 +448,7 @@ loop_end:
|
|||||||
|
|
||||||
WSACloseEvent(events[0]);
|
WSACloseEvent(events[0]);
|
||||||
|
|
||||||
assert(unregister_subprocess(info->proc) != -1);
|
ncat_assert(unregister_subprocess(info->proc) != -1);
|
||||||
|
|
||||||
GetExitCodeProcess(info->proc, &ret);
|
GetExitCodeProcess(info->proc, &ret);
|
||||||
if (ret == STILL_ACTIVE) {
|
if (ret == STILL_ACTIVE) {
|
||||||
@@ -472,10 +470,10 @@ loop_end:
|
|||||||
subprocess_info_close(info);
|
subprocess_info_close(info);
|
||||||
free(info);
|
free(info);
|
||||||
|
|
||||||
assert(WaitForSingleObject(pseudo_sigchld_mutex, INFINITE) == WAIT_OBJECT_0);
|
ncat_assert(WaitForSingleObject(pseudo_sigchld_mutex, INFINITE) == WAIT_OBJECT_0);
|
||||||
if (pseudo_sigchld_handler != NULL)
|
if (pseudo_sigchld_handler != NULL)
|
||||||
pseudo_sigchld_handler();
|
pseudo_sigchld_handler();
|
||||||
assert(ReleaseMutex(pseudo_sigchld_mutex) != 0);
|
ncat_assert(ReleaseMutex(pseudo_sigchld_mutex) != 0);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -488,7 +486,7 @@ static int get_subprocess_slot(void)
|
|||||||
{
|
{
|
||||||
int i, free_index, max_index;
|
int i, free_index, max_index;
|
||||||
|
|
||||||
assert(WaitForSingleObject(subprocesses_mutex, INFINITE) == WAIT_OBJECT_0);
|
ncat_assert(WaitForSingleObject(subprocesses_mutex, INFINITE) == WAIT_OBJECT_0);
|
||||||
|
|
||||||
free_index = -1;
|
free_index = -1;
|
||||||
max_index = 0;
|
max_index = 0;
|
||||||
@@ -508,7 +506,7 @@ static int get_subprocess_slot(void)
|
|||||||
free_index = max_index++;
|
free_index = max_index++;
|
||||||
subprocess_max_index = max_index;
|
subprocess_max_index = max_index;
|
||||||
|
|
||||||
assert(ReleaseMutex(subprocesses_mutex) != 0);
|
ncat_assert(ReleaseMutex(subprocesses_mutex) != 0);
|
||||||
|
|
||||||
return free_index;
|
return free_index;
|
||||||
}
|
}
|
||||||
@@ -523,14 +521,14 @@ static int register_subprocess(HANDLE proc)
|
|||||||
|
|
||||||
if (subprocesses_mutex == NULL) {
|
if (subprocesses_mutex == NULL) {
|
||||||
subprocesses_mutex = CreateMutex(NULL, FALSE, NULL);
|
subprocesses_mutex = CreateMutex(NULL, FALSE, NULL);
|
||||||
assert(subprocesses_mutex != NULL);
|
ncat_assert(subprocesses_mutex != NULL);
|
||||||
}
|
}
|
||||||
if (pseudo_sigchld_mutex == NULL) {
|
if (pseudo_sigchld_mutex == NULL) {
|
||||||
pseudo_sigchld_mutex = CreateMutex(NULL, FALSE, NULL);
|
pseudo_sigchld_mutex = CreateMutex(NULL, FALSE, NULL);
|
||||||
assert(pseudo_sigchld_mutex != NULL);
|
ncat_assert(pseudo_sigchld_mutex != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(WaitForSingleObject(subprocesses_mutex, INFINITE) == WAIT_OBJECT_0);
|
ncat_assert(WaitForSingleObject(subprocesses_mutex, INFINITE) == WAIT_OBJECT_0);
|
||||||
|
|
||||||
i = get_subprocess_slot();
|
i = get_subprocess_slot();
|
||||||
if (i == -1) {
|
if (i == -1) {
|
||||||
@@ -551,7 +549,7 @@ static int register_subprocess(HANDLE proc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(ReleaseMutex(subprocesses_mutex) != 0);
|
ncat_assert(ReleaseMutex(subprocesses_mutex) != 0);
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@@ -562,7 +560,7 @@ static int unregister_subprocess(HANDLE proc)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
assert(WaitForSingleObject(subprocesses_mutex, INFINITE) == WAIT_OBJECT_0);
|
ncat_assert(WaitForSingleObject(subprocesses_mutex, INFINITE) == WAIT_OBJECT_0);
|
||||||
|
|
||||||
for (i = 0; i < subprocess_max_index; i++) {
|
for (i = 0; i < subprocess_max_index; i++) {
|
||||||
if (proc == subprocesses[i])
|
if (proc == subprocesses[i])
|
||||||
@@ -576,7 +574,7 @@ static int unregister_subprocess(HANDLE proc)
|
|||||||
i = -1;
|
i = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(ReleaseMutex(subprocesses_mutex) != 0);
|
ncat_assert(ReleaseMutex(subprocesses_mutex) != 0);
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@@ -588,7 +586,7 @@ static void terminate_subprocesses(void)
|
|||||||
if (o.debug)
|
if (o.debug)
|
||||||
logdebug("Terminating subprocesses\n");
|
logdebug("Terminating subprocesses\n");
|
||||||
|
|
||||||
assert(WaitForSingleObject(subprocesses_mutex, INFINITE) == WAIT_OBJECT_0);
|
ncat_assert(WaitForSingleObject(subprocesses_mutex, INFINITE) == WAIT_OBJECT_0);
|
||||||
|
|
||||||
if (o.debug > 1)
|
if (o.debug > 1)
|
||||||
logdebug("max_index %d\n", subprocess_max_index);
|
logdebug("max_index %d\n", subprocess_max_index);
|
||||||
@@ -607,7 +605,7 @@ static void terminate_subprocesses(void)
|
|||||||
subprocesses[i] = NULL;
|
subprocesses[i] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(ReleaseMutex(subprocesses_mutex) != 0);
|
ncat_assert(ReleaseMutex(subprocesses_mutex) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sigint_handler(int s)
|
static void sigint_handler(int s)
|
||||||
|
|||||||
@@ -91,7 +91,6 @@
|
|||||||
|
|
||||||
#include "ncat.h"
|
#include "ncat.h"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -183,7 +182,7 @@ static int get_conn_count(void)
|
|||||||
conn_dec_changed = 0;
|
conn_dec_changed = 0;
|
||||||
count = conn_inc - conn_dec;
|
count = conn_inc - conn_dec;
|
||||||
} while (conn_dec_changed);
|
} while (conn_dec_changed);
|
||||||
assert(count <= INT_MAX);
|
ncat_assert(count <= INT_MAX);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,8 +89,6 @@
|
|||||||
|
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include "ncat.h"
|
#include "ncat.h"
|
||||||
|
|
||||||
char **cmdline_split(const char *cmdexec);
|
char **cmdline_split(const char *cmdexec);
|
||||||
@@ -350,7 +348,7 @@ int ssl_load_default_ca_certs(SSL_CTX *ctx)
|
|||||||
logdebug("Using system default trusted CA certificates and those in %s.\n", NCAT_CA_CERTS_PATH);
|
logdebug("Using system default trusted CA certificates and those in %s.\n", NCAT_CA_CERTS_PATH);
|
||||||
|
|
||||||
/* Load distribution-provided defaults, if any. */
|
/* Load distribution-provided defaults, if any. */
|
||||||
assert(SSL_CTX_set_default_verify_paths(ctx) > 0);
|
ncat_assert(SSL_CTX_set_default_verify_paths(ctx) > 0);
|
||||||
|
|
||||||
/* Also load the trusted certificates we ship. */
|
/* Also load the trusted certificates we ship. */
|
||||||
rc = SSL_CTX_load_verify_locations(ctx, NCAT_CA_CERTS_PATH, NULL);
|
rc = SSL_CTX_load_verify_locations(ctx, NCAT_CA_CERTS_PATH, NULL);
|
||||||
|
|||||||
@@ -95,7 +95,6 @@
|
|||||||
#include "nsock.h"
|
#include "nsock.h"
|
||||||
#include "ncat.h"
|
#include "ncat.h"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
@@ -160,7 +159,7 @@ SSL_CTX *setup_ssl_listen(void)
|
|||||||
if (ssl_gen_cert(&cert, &key) == 0)
|
if (ssl_gen_cert(&cert, &key) == 0)
|
||||||
bye("ssl_gen_cert(): %s.", ERR_error_string(ERR_get_error(), NULL));
|
bye("ssl_gen_cert(): %s.", ERR_error_string(ERR_get_error(), NULL));
|
||||||
if (o.verbose) {
|
if (o.verbose) {
|
||||||
assert(ssl_cert_fp_str_sha1(cert, digest_buf, sizeof(digest_buf)) != NULL);
|
ncat_assert(ssl_cert_fp_str_sha1(cert, digest_buf, sizeof(digest_buf)) != NULL);
|
||||||
loguser("SHA-1 fingerprint: %s\n", digest_buf);
|
loguser("SHA-1 fingerprint: %s\n", digest_buf);
|
||||||
}
|
}
|
||||||
if (SSL_CTX_use_certificate(sslctx, cert) != 1)
|
if (SSL_CTX_use_certificate(sslctx, cert) != 1)
|
||||||
@@ -562,7 +561,7 @@ char *ssl_cert_fp_str_sha1(const X509 *cert, char *strbuf, size_t len)
|
|||||||
Snprintf(p, 3, "%02X", binbuf[i]);
|
Snprintf(p, 3, "%02X", binbuf[i]);
|
||||||
p += 2;
|
p += 2;
|
||||||
}
|
}
|
||||||
assert(p - strbuf <= len);
|
ncat_assert(p - strbuf <= len);
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
|
|
||||||
return strbuf;
|
return strbuf;
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ dNSNames, then checks that matching names are accepted and non-matching names
|
|||||||
are rejected. The SSL transactions happen over OpenSSL BIO pairs.
|
are rejected. The SSL transactions happen over OpenSSL BIO pairs.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -68,28 +67,28 @@ static int test(const struct lstr commonNames[], const struct lstr dNSNames[],
|
|||||||
|
|
||||||
tests_run++;
|
tests_run++;
|
||||||
|
|
||||||
assert(gen_cert(&cert, &key, commonNames, dNSNames) == 1);
|
ncat_assert(gen_cert(&cert, &key, commonNames, dNSNames) == 1);
|
||||||
|
|
||||||
assert(BIO_new_bio_pair(&server_bio, 0, &client_bio, 0) == 1);
|
ncat_assert(BIO_new_bio_pair(&server_bio, 0, &client_bio, 0) == 1);
|
||||||
|
|
||||||
server_ctx = SSL_CTX_new(SSLv23_server_method());
|
server_ctx = SSL_CTX_new(SSLv23_server_method());
|
||||||
assert(server_ctx != NULL);
|
ncat_assert(server_ctx != NULL);
|
||||||
|
|
||||||
client_ctx = SSL_CTX_new(SSLv23_client_method());
|
client_ctx = SSL_CTX_new(SSLv23_client_method());
|
||||||
assert(client_ctx != NULL);
|
ncat_assert(client_ctx != NULL);
|
||||||
SSL_CTX_set_verify(client_ctx, SSL_VERIFY_PEER, NULL);
|
SSL_CTX_set_verify(client_ctx, SSL_VERIFY_PEER, NULL);
|
||||||
SSL_CTX_set_verify_depth(client_ctx, 1);
|
SSL_CTX_set_verify_depth(client_ctx, 1);
|
||||||
ssl_ctx_trust_cert(client_ctx, cert);
|
ssl_ctx_trust_cert(client_ctx, cert);
|
||||||
|
|
||||||
server_ssl = SSL_new(server_ctx);
|
server_ssl = SSL_new(server_ctx);
|
||||||
assert(server_ssl != NULL);
|
ncat_assert(server_ssl != NULL);
|
||||||
SSL_set_accept_state(server_ssl);
|
SSL_set_accept_state(server_ssl);
|
||||||
SSL_set_bio(server_ssl, server_bio, server_bio);
|
SSL_set_bio(server_ssl, server_bio, server_bio);
|
||||||
assert(SSL_use_certificate(server_ssl, cert) == 1);
|
ncat_assert(SSL_use_certificate(server_ssl, cert) == 1);
|
||||||
assert(SSL_use_PrivateKey(server_ssl, key) == 1);
|
ncat_assert(SSL_use_PrivateKey(server_ssl, key) == 1);
|
||||||
|
|
||||||
client_ssl = SSL_new(client_ctx);
|
client_ssl = SSL_new(client_ctx);
|
||||||
assert(client_ssl != NULL);
|
ncat_assert(client_ssl != NULL);
|
||||||
SSL_set_connect_state(client_ssl);
|
SSL_set_connect_state(client_ssl);
|
||||||
SSL_set_bio(client_ssl, client_bio, client_bio);
|
SSL_set_bio(client_ssl, client_bio, client_bio);
|
||||||
|
|
||||||
@@ -530,7 +529,7 @@ void test_specificity(const struct lstr patterns[],
|
|||||||
|
|
||||||
for (i = 0; i < ARR_LEN && !is_sentinel(&patterns[i]); i++)
|
for (i = 0; i < ARR_LEN && !is_sentinel(&patterns[i]); i++)
|
||||||
scratch[i] = patterns[i];
|
scratch[i] = patterns[i];
|
||||||
assert(i < ARR_LEN);
|
ncat_assert(i < ARR_LEN);
|
||||||
scratch[i] = lstr_sentinel;
|
scratch[i] = lstr_sentinel;
|
||||||
|
|
||||||
test(scratch, NULL, test_names, expected_forward);
|
test(scratch, NULL, test_names, expected_forward);
|
||||||
|
|||||||
@@ -95,7 +95,6 @@
|
|||||||
#include "nbase.h"
|
#include "nbase.h"
|
||||||
#include "sockaddr_u.h"
|
#include "sockaddr_u.h"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <iphlpapi.h>
|
#include <iphlpapi.h>
|
||||||
@@ -212,7 +211,7 @@ void zmem(void *mem, size_t n)
|
|||||||
buffer and updates the variables to make room if necessary. */
|
buffer and updates the variables to make room if necessary. */
|
||||||
int strbuf_append(char **buf, size_t *size, size_t *offset, const char *s, size_t n)
|
int strbuf_append(char **buf, size_t *size, size_t *offset, const char *s, size_t n)
|
||||||
{
|
{
|
||||||
assert(*offset <= *size);
|
ncat_assert(*offset <= *size);
|
||||||
|
|
||||||
if (n >= *size - *offset) {
|
if (n >= *size - *offset) {
|
||||||
*size += n + 1;
|
*size += n + 1;
|
||||||
@@ -239,7 +238,7 @@ int strbuf_sprintf(char **buf, size_t *size, size_t *offset, const char *fmt, ..
|
|||||||
va_list va;
|
va_list va;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
assert(*offset <= *size);
|
ncat_assert(*offset <= *size);
|
||||||
|
|
||||||
if (*buf == NULL) {
|
if (*buf == NULL) {
|
||||||
*size = 1;
|
*size = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user