diff options
author | Simon Rettberg | 2019-06-21 12:08:35 +0200 |
---|---|---|
committer | Simon Rettberg | 2019-06-21 12:08:35 +0200 |
commit | 73218929a6a9d817608df58be6cd23e2f1ec701f (patch) | |
tree | 7fb9287f84b99c6e9796e4d3a69295436db0245b | |
parent | Add STARTTLS support (diff) | |
download | ldadp-73218929a6a9d817608df58be6cd23e2f1ec701f.tar.gz ldadp-73218929a6a9d817608df58be6cd23e2f1ec701f.tar.xz ldadp-73218929a6a9d817608df58be6cd23e2f1ec701f.zip |
Empty read buffer in cleanup; better log messages
-rw-r--r-- | server.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -469,7 +469,7 @@ void server_free(epoll_server_t *server) close(server->fd); server->fd = -1; } - server->sbPos = server->sbFill = 0; + server->rbPos = server->sbPos = server->sbFill = server->bindLen = 0; if (server->dynamic) { printf("[Server] Freeing Bind-AD-Connection\n"); free(server->sendBuffer); @@ -576,7 +576,7 @@ static void server_haveIn(epoll_server_t *server) BOOL server_send(epoll_server_t *server, const char *buffer, size_t len, const BOOL cork) { if (server->kill) return FALSE; - if (server->ssl == NULL && server->sbFill == 0 && !cork) { + if (server->ssl == NULL && server->sbFill == 0 && !cork && server->startTlsId == 0) { // Nothing in send buffer, fire away const int ret = write(server->fd, buffer, len); if (ret == 0 || (ret < 0 && errno != EINTR && errno != EAGAIN)) { @@ -832,11 +832,12 @@ static BOOL server_handleStartTlsResponse(epoll_server_t *server, const size_t m return FALSE; } if (messageId != server->startTlsId) { - printf("[Server] STARTTLS reply doesn't have expected message id\n"); + printf("[Server] STARTTLS reply doesn't have expected message id (want %d is %d)\n", + (int)server->startTlsId, (int)messageId); return FALSE; } if (op != ExtendedResponse) { - printf("[Server] STARTTLS reply doesn't have op ExtendedResponse\n"); + printf("[Server] STARTTLS reply doesn't have op ExtendedResponse but %d\n", (int)op); return FALSE; } enum asn1_tagclass tc; @@ -849,11 +850,11 @@ static BOOL server_handleStartTlsResponse(epoll_server_t *server, const size_t m return FALSE; } if (tag != ENUMERATED && tag != INTEGER) { - printf("[Server] STARTTLS reply doesn't contain resultCode\n"); + printf("[Server] STARTTLS reply doesn't contain resultCode (INT/ENUM) but tag %d\n", (int)tag); return FALSE; } if (value != 0) { - printf("[Server] STARTTLS reply has resultCode != 0\n"); + printf("[Server] STARTTLS reply has resultCode == %d\n", (int)value); return FALSE; } if (!server_connectSsl(server)) { |