summaryrefslogtreecommitdiff
path: root/sockets.c
diff options
context:
space:
mode:
Diffstat (limited to 'sockets.c')
-rw-r--r--sockets.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/sockets.c b/sockets.c
index c075232..0921e55 100644
--- a/sockets.c
+++ b/sockets.c
@@ -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 {