Add compile-time check for POLARSSL_VERSION_FEATURES before using version_get_string().
[umurmur.git] / src / ssli_polarssl.c
index b553f796cee0e2c73f6451838268eb54cf4af3c0..167637b9d71fed4ad83787bfba2622f5bd5d7c7f 100644 (file)
    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
-#include <string.h>
-#include <stdlib.h>
-#include <fcntl.h>
-
 #include "conf.h"
 #include "log.h"
 #include "ssl.h"
 
-/*
- * PolarSSL interface
- */
+#include <stdlib.h>
+#include <fcntl.h>
 
 #include <polarssl/config.h>
 #include <polarssl/havege.h>
@@ -230,8 +225,12 @@ void SSLi_init(void)
            Log_fatal("Cannot open /dev/urandom");
 #endif
 
+#ifdef POLARSSL_VERSION_FEATURES
     version_get_string(verstring);
     Log_info("PolarSSL library version %s initialized", verstring);
+#else
+    Log_info("PolarSSL library initialized");
+#endif
 }
 
 void SSLi_deinit(void)
@@ -270,12 +269,10 @@ SSL_handle_t *SSLi_newconnection(int *fd, bool_t *SSLready)
        ssl_session *ssn;
        int rc;
 
-       ssl = malloc(sizeof(ssl_context));
-       ssn = malloc(sizeof(ssl_session));
+       ssl = calloc(1, sizeof(ssl_context));
+       ssn = calloc(1, sizeof(ssl_session));
        if (!ssl || !ssn)
                Log_fatal("Out of memory");
-       memset(ssl, 0, sizeof(ssl_context));
-       memset(ssn, 0, sizeof(ssl_session));
 
        rc = ssl_init(ssl);
        if (rc != 0 )