From f6230971a7b67fbbf8afdd6ee51b3d8d6dfb8504 Mon Sep 17 00:00:00 2001 From: SJ Date: Mon, 28 Dec 2015 15:07:27 +0100 Subject: [PATCH] code cleanup --- src/config.h | 2 +- unit_tests/smtp.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/config.h b/src/config.h index a3d832a1..ec441186 100644 --- a/src/config.h +++ b/src/config.h @@ -13,7 +13,7 @@ #define VERSION "1.2.0-master" -#define BUILD 932 +#define BUILD 933 #define HOSTID "mailarchiver" diff --git a/unit_tests/smtp.c b/unit_tests/smtp.c index 1bf5700c..dae12464 100644 --- a/unit_tests/smtp.c +++ b/unit_tests/smtp.c @@ -40,6 +40,7 @@ void usage(){ void send_smtp_command(int sd, char *cmd, char *buf, int buflen, int timeout, int use_ssl, struct __data *data){ + if(data == NULL || cmd == NULL) return; printf("sent: %s", cmd); write1(sd, cmd, strlen(cmd), use_ssl, data->ssl); @@ -54,6 +55,8 @@ static void test_smtp_commands_one_at_a_time(char *server, int port, int timeout char recvbuf[MAXBUFSIZE], sendbuf[MAXBUFSIZE]; struct __data data; + data.ssl = NULL; + sd = connect_to_smtp_server(server, port, timeout, use_ssl, &data); send_smtp_command(sd, "HELO aaaa.fu\r\n", recvbuf, sizeof(recvbuf)-1, timeout, use_ssl, &data); @@ -85,6 +88,8 @@ static void test_smtp_commands_pipelining(char *server, int port, int timeout){ char recvbuf[MAXBUFSIZE], sendbuf[MAXBUFSIZE]; struct __data data; + data.ssl = NULL; + sd = connect_to_smtp_server(server, port, timeout, use_ssl, &data); send_smtp_command(sd, "HELO aaaa.fu\r\n", recvbuf, sizeof(recvbuf)-1, timeout, use_ssl, &data); @@ -107,6 +112,8 @@ static void test_smtp_commands_with_reset_command(char *server, int port, int ti char recvbuf[MAXBUFSIZE]; struct __data data; + data.ssl = NULL; + sd = connect_to_smtp_server(server, port, timeout, use_ssl, &data); send_smtp_command(sd, "HELO aaaa.fu\r\n", recvbuf, sizeof(recvbuf)-1, timeout, use_ssl, &data); @@ -133,6 +140,8 @@ static void test_smtp_commands_partial_command(char *server, int port, int timeo char recvbuf[MAXBUFSIZE], sendbuf[MAXBUFSIZE]; struct __data data; + data.ssl = NULL; + sd = connect_to_smtp_server(server, port, timeout, use_ssl, &data); send_smtp_command(sd, "HELO aaaa.fu\r\n", recvbuf, sizeof(recvbuf)-1, timeout, use_ssl, &data); @@ -167,6 +176,8 @@ static void test_smtp_commands_partial_command_pipelining(char *server, int port char recvbuf[MAXBUFSIZE], sendbuf[MAXBUFSIZE]; struct __data data; + data.ssl = NULL; + sd = connect_to_smtp_server(server, port, timeout, use_ssl, &data); send_smtp_command(sd, "HELO aaaa.fu\r\n", recvbuf, sizeof(recvbuf)-1, timeout, use_ssl, &data); @@ -192,6 +203,8 @@ int connect_to_smtp_server(char *server, int port, int timeout, int use_ssl, str char port_string[8], buf[MAXBUFSIZE]; struct addrinfo hints, *res; + if(data == NULL) return sd; + snprintf(port_string, sizeof(port_string)-1, "%d", port); memset(&hints, 0, sizeof(hints));