diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2011-09-23 14:22:33 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2011-09-23 14:23:07 +0200 |
commit | 56120e2caabc4b7becbd961187a4aa92e3534215 (patch) | |
tree | bccaeb6ab40b94bd888232a40e7638df8c3a88b3 | |
parent | 8aae368bd1fb38e83ae2dc1de9c46e9d99252f21 (diff) | |
download | gnutls-56120e2caabc4b7becbd961187a4aa92e3534215.tar.gz |
Further optimizations in the compression code. Re-enabled the test program by suppressing the zlib warning.
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | gl/m4/valgrind-tests.m4 | 2 | ||||
-rw-r--r-- | gl/override/m4/valgrind-tests.m4.diff | 2 | ||||
-rw-r--r-- | lib/gnutls_cipher.c | 4 | ||||
-rw-r--r-- | lib/gnutls_compress.c | 48 | ||||
-rw-r--r-- | lib/gnutls_compress.h | 12 | ||||
-rw-r--r-- | lib/gnutls_constate.c | 12 | ||||
-rw-r--r-- | lib/gnutls_int.h | 2 | ||||
-rw-r--r-- | tests/Makefile.am | 9 | ||||
-rw-r--r-- | tests/safe-renegotiation/Makefile.am | 2 | ||||
-rw-r--r-- | tests/safe-renegotiation/suppressions.valgrind | 0 | ||||
-rw-r--r-- | tests/suppressions.valgrind (renamed from tests/libgcrypt.supp) | 20 |
12 files changed, 58 insertions, 57 deletions
@@ -4,6 +4,8 @@ See the end for copying conditions. * Version 3.0.4 (unreleased) +** libgnutls: Fixed the deflate compression code. + ** libgnutls: Added gnutls_x509_crt_get_authority_info_access. Used to get the PKIX Authority Information Access (AIA) field. diff --git a/gl/m4/valgrind-tests.m4 b/gl/m4/valgrind-tests.m4 index 98d4487857..9c4d0290c6 100644 --- a/gl/m4/valgrind-tests.m4 +++ b/gl/m4/valgrind-tests.m4 @@ -23,7 +23,7 @@ AC_DEFUN([gl_VALGRIND_TESTS], if test -n "$VALGRIND" && $VALGRIND -q true > /dev/null 2>&1; then opt_valgrind_tests=yes - VALGRIND="$VALGRIND -q --error-exitcode=1" + VALGRIND="$VALGRIND -q --error-exitcode=1 --suppressions=suppressions.valgrind" else opt_valgrind_tests=no VALGRIND= diff --git a/gl/override/m4/valgrind-tests.m4.diff b/gl/override/m4/valgrind-tests.m4.diff index 8a4f643af1..dac9a243f6 100644 --- a/gl/override/m4/valgrind-tests.m4.diff +++ b/gl/override/m4/valgrind-tests.m4.diff @@ -5,7 +5,7 @@ if test -n "$VALGRIND" && $VALGRIND -q true > /dev/null 2>&1; then opt_valgrind_tests=yes - VALGRIND="$VALGRIND -q --error-exitcode=1 --leak-check=full" -+ VALGRIND="$VALGRIND -q --error-exitcode=1" ++ VALGRIND="$VALGRIND -q --error-exitcode=1 --suppressions=suppressions.valgrind" else opt_valgrind_tests=no VALGRIND= diff --git a/lib/gnutls_cipher.c b/lib/gnutls_cipher.c index 75ca6ab090..716b7c9bd2 100644 --- a/lib/gnutls_cipher.c +++ b/lib/gnutls_cipher.c @@ -105,7 +105,7 @@ _gnutls_encrypt (gnutls_session_t session, const opaque * headers, if (comp.data == NULL) return gnutls_assert_val(GNUTLS_E_MEMORY_ERROR); - ret = _gnutls_compress( params->write.compression_state, data, data_size, comp.data, comp.size); + ret = _gnutls_compress( ¶ms->write.compression_state, data, data_size, comp.data, comp.size); if (ret < 0) { gnutls_free(comp.data); @@ -182,7 +182,7 @@ _gnutls_decrypt (gnutls_session_t session, opaque * ciphertext, if (ret != 0) { - ret = _gnutls_decompress(params->read.compression_state, tmp_data, data_size, data, max_data_size); + ret = _gnutls_decompress( ¶ms->read.compression_state, tmp_data, data_size, data, max_data_size); if (ret < 0) goto leave; } diff --git a/lib/gnutls_compress.c b/lib/gnutls_compress.c index d682511a71..3821a84879 100644 --- a/lib/gnutls_compress.c +++ b/lib/gnutls_compress.c @@ -241,20 +241,10 @@ _gnutls_supported_compression_methods (gnutls_session_t session, /* The flag d is the direction (compress, decompress). Non zero is * decompress. */ -comp_hd_t -_gnutls_comp_init (gnutls_compression_method_t method, int d) +int _gnutls_comp_init (comp_hd_st* handle, gnutls_compression_method_t method, int d) { - comp_hd_t ret; - - ret = gnutls_malloc (sizeof (struct comp_hd_t_STRUCT)); - if (ret == NULL) - { - gnutls_assert (); - return NULL; - } - - ret->algo = method; - ret->handle = NULL; + handle->algo = method; + handle->handle = NULL; switch (method) { @@ -270,14 +260,11 @@ _gnutls_comp_init (gnutls_compression_method_t method, int d) mem_level = get_mem_level (method); comp_level = get_comp_level (method); - ret->handle = gnutls_malloc (sizeof (z_stream)); - if (ret->handle == NULL) - { - gnutls_assert (); - goto cleanup_ret; - } + handle->handle = gnutls_malloc (sizeof (z_stream)); + if (handle->handle == NULL) + return gnutls_assert_val(GNUTLS_E_MEMORY_ERROR); - zhandle = ret->handle; + zhandle = handle->handle; zhandle->zalloc = (alloc_func) 0; zhandle->zfree = (free_func) 0; @@ -294,8 +281,8 @@ _gnutls_comp_init (gnutls_compression_method_t method, int d) if (err != Z_OK) { gnutls_assert (); - gnutls_free (ret->handle); - goto cleanup_ret; + gnutls_free (handle->handle); + return GNUTLS_E_COMPRESSION_FAILED; } } break; @@ -303,20 +290,18 @@ _gnutls_comp_init (gnutls_compression_method_t method, int d) case GNUTLS_COMP_NULL: case GNUTLS_COMP_UNKNOWN: break; + default: + return GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM; } - return ret; - -cleanup_ret: - gnutls_free (ret); - return NULL; + return 0; } /* The flag d is the direction (compress, decompress). Non zero is * decompress. */ void -_gnutls_comp_deinit (comp_hd_t handle, int d) +_gnutls_comp_deinit (comp_hd_st* handle, int d) { if (handle != NULL) { @@ -336,8 +321,7 @@ _gnutls_comp_deinit (comp_hd_t handle, int d) break; } gnutls_free (handle->handle); - gnutls_free (handle); - + handle->handle = NULL; } } @@ -345,7 +329,7 @@ _gnutls_comp_deinit (comp_hd_t handle, int d) */ int -_gnutls_compress (comp_hd_t handle, const opaque * plain, +_gnutls_compress (comp_hd_st *handle, const opaque * plain, size_t plain_size, opaque * compressed, size_t max_comp_size) { @@ -399,7 +383,7 @@ _gnutls_compress (comp_hd_t handle, const opaque * plain, int -_gnutls_decompress (comp_hd_t handle, opaque * compressed, +_gnutls_decompress (comp_hd_st *handle, opaque * compressed, size_t compressed_size, opaque * plain, size_t max_plain_size) { diff --git a/lib/gnutls_compress.h b/lib/gnutls_compress.h index 7f3545cbd5..559906da8b 100644 --- a/lib/gnutls_compress.h +++ b/lib/gnutls_compress.h @@ -35,19 +35,19 @@ gnutls_compression_method_t _gnutls_compression_get_id (int num); #define GNUTLS_COMP_FAILED NULL -typedef struct comp_hd_t_STRUCT +typedef struct comp_hd_st { void *handle; gnutls_compression_method_t algo; -} *comp_hd_t; +} comp_hd_st; -comp_hd_t _gnutls_comp_init (gnutls_compression_method_t, int d); -void _gnutls_comp_deinit (comp_hd_t handle, int d); +int _gnutls_comp_init (comp_hd_st*, gnutls_compression_method_t, int d); +void _gnutls_comp_deinit (comp_hd_st* handle, int d); -int _gnutls_decompress (comp_hd_t handle, opaque * compressed, +int _gnutls_decompress (comp_hd_st* handle, opaque * compressed, size_t compressed_size, opaque * plain, size_t max_plain_size); -int _gnutls_compress (comp_hd_t, const opaque * plain, size_t plain_size, +int _gnutls_compress (comp_hd_st*, const opaque * plain, size_t plain_size, opaque * compressed, size_t max_comp_size); struct gnutls_compression_entry diff --git a/lib/gnutls_constate.c b/lib/gnutls_constate.c index d747cc3949..6d259401f6 100644 --- a/lib/gnutls_constate.c +++ b/lib/gnutls_constate.c @@ -306,11 +306,11 @@ _gnutls_init_record_state (record_parameters_st * params, gnutls_protocol_t ver, if (ret < 0 && params->cipher_algorithm != GNUTLS_CIPHER_NULL) return gnutls_assert_val (ret); - state->compression_state = - _gnutls_comp_init (params->compression_algorithm, read/*1==decompress*/); + ret = + _gnutls_comp_init (&state->compression_state, params->compression_algorithm, read/*1==decompress*/); - if (state->compression_state == GNUTLS_COMP_FAILED) - return gnutls_assert_val (GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM); + if (ret < 0) + return gnutls_assert_val (ret); return 0; } @@ -815,8 +815,8 @@ free_record_state (record_state_st * state, int d) _gnutls_auth_cipher_deinit (&state->cipher_state); - if (state->compression_state != NULL) - _gnutls_comp_deinit (state->compression_state, d); + if (state->compression_state.handle != NULL) + _gnutls_comp_deinit (&state->compression_state, d); } void diff --git a/lib/gnutls_int.h b/lib/gnutls_int.h index 9b0b8bf7c0..d47ce5935d 100644 --- a/lib/gnutls_int.h +++ b/lib/gnutls_int.h @@ -495,7 +495,7 @@ struct record_state_st gnutls_datum_t IV; gnutls_datum_t key; auth_cipher_hd_st cipher_state; - comp_hd_t compression_state; + comp_hd_st compression_state; uint64 sequence_number; }; diff --git a/tests/Makefile.am b/tests/Makefile.am index 23c0bae0bc..08104a70bf 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -30,7 +30,7 @@ if WANT_TEST_SUITE SUBDIRS += suite endif -EXTRA_DIST = libgcrypt.supp eagain-common.h +EXTRA_DIST = suppressions.valgrind eagain-common.h AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) AM_CPPFLAGS = \ @@ -57,16 +57,15 @@ endif noinst_LTLIBRARIES = libutils.la libutils_la_SOURCES = utils.h utils.c -ctests = simple gc set_pkcs12_cred certder certuniqueid mpi \ +ctests = mini-deflate simple gc set_pkcs12_cred certder certuniqueid mpi \ certificate_set_x509_crl dn parse_ca moredn mini \ hostname-check cve-2008-4989 pkcs12_s2k chainverify crq_key_id \ x509sign-verify cve-2009-1415 cve-2009-1416 crq_apis \ init_roundtrip pkcs12_s2k_pem dn2 mini-eagain \ nul-in-x509-names x509_altname pkcs12_encode mini-x509 \ mini-x509-rehandshake rng-fork mini-eagain-dtls cipher-test \ - x509cert x509cert-tl infoaccess #gendh mini-deflate -#gendh is out because it is too slow in valgrind and -#mini-deflate is out because zlib has warnings in valgrind + x509cert x509cert-tl infoaccess #gendh +#gendh is out because it is too slow in valgrind if ENABLE_OPENSSL ctests += openssl diff --git a/tests/safe-renegotiation/Makefile.am b/tests/safe-renegotiation/Makefile.am index 8b0c65833a..17d4684df7 100644 --- a/tests/safe-renegotiation/Makefile.am +++ b/tests/safe-renegotiation/Makefile.am @@ -32,4 +32,4 @@ check_PROGRAMS = $(ctests) TESTS = $(ctests) TESTS_ENVIRONMENT = $(VALGRIND) -EXTRA_DIST = README +EXTRA_DIST = README suppressions.valgrind diff --git a/tests/safe-renegotiation/suppressions.valgrind b/tests/safe-renegotiation/suppressions.valgrind new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/safe-renegotiation/suppressions.valgrind diff --git a/tests/libgcrypt.supp b/tests/suppressions.valgrind index 3766b25702..57c4222e2a 100644 --- a/tests/libgcrypt.supp +++ b/tests/suppressions.valgrind @@ -1,12 +1,28 @@ -# libgcrypt.supp -- Valgrind suppresion file for libgcrypt +# suppressions -- Valgrind suppresion file for libgcrypt -# Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. +# Copyright (C) 2008-2011 Free Software Foundation, Inc. # Copying and distribution of this file, with or without modification, # are permitted in any medium without royalty provided the copyright # notice and this notice are preserved. { + zlib inflateInit + Memcheck:Cond + fun:inflateReset2 + fun:inflateInit2_ + fun:_gnutls_comp_init + fun:_gnutls_init_record_state + fun:_gnutls_epoch_set_keys + fun:_gnutls_write_connection_state_init + fun:_gnutls_send_handshake_final + fun:_gnutls_handshake_common + fun:gnutls_handshake + fun:doit + fun:main +} + +{ libgcrypt1 Memcheck:Leak fun:malloc |