diff options
Diffstat (limited to 'sockets.c')
-rw-r--r-- | sockets.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -210,6 +210,11 @@ void configure_openssl_context(SSL_CTX *ctx, char *certfile, char *keyfile) { // Read from a socket, whether or not using TLS int sockread(SSL *fd, char *buf, int bufsize, int tls) { + if (fd == NULL) { + debugprint(DEBUG_CRIT, "sockread(): error: fd is NULL, returning.\n"); + return -1; + } + if (tls) { return SSL_read(fd, buf, bufsize); } else { @@ -220,6 +225,11 @@ int sockread(SSL *fd, char *buf, int bufsize, int tls) { // Write to a socket, whether or not using TLS int socksend(SSL *fd, char *buf, int bufsize, int tls) { + if (fd == NULL) { + debugprint(DEBUG_CRIT, "socksend(): error: fd is NULL, returning.\n"); + return -1; + } + if (tls) { return SSL_write(fd, buf, bufsize); } else { |