[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gnutls-dev] GNUTLS_E_INTERNAL_ERROR in _gnutls_ciphertext2compresse
From: |
Ludovic Courtès |
Subject: |
Re: [gnutls-dev] GNUTLS_E_INTERNAL_ERROR in _gnutls_ciphertext2compressed |
Date: |
Thu, 15 Nov 2007 14:27:10 +0100 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) |
Hi,
"Nikos Mavrogiannopoulos" <address@hidden> writes:
> I think I've solved it in the git repository. Could you check if my changes
> solve the problem for you? (you can check the gnutls_2_0_x branch for the
> stable patch).
I can't directly switch to 2.0.3, so I used 2.0.1 with the attached
patch (your last 2 commits on the `gnutls_2_0_x' branch).
Unfortunately, that doesn't fix the problem: I'm still getting a
`_gnutls_decrypt ()' failure (`GNUTLS_E_DECRYPTION_FAILED' this time) at
`gnutls_record.c:988'.
Again, I'm using the `NULL' compression method.
Thanks,
Ludovic.
diff --git a/lib/gnutls_cipher.c b/lib/gnutls_cipher.c
index b2420f7..2dbbf8d 100644
--- a/lib/gnutls_cipher.c
+++ b/lib/gnutls_cipher.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation
+ * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007 Free Software
Foundation
*
* Author: Nikos Mavroyanopoulos
*
@@ -91,7 +91,7 @@ _gnutls_encrypt (gnutls_session_t session, const opaque *
headers,
/* Here comp is allocated and must be
* freed.
*/
- ret = _gnutls_m_plaintext2compressed (session, &comp, plain);
+ ret = _gnutls_m_plaintext2compressed (session, &comp, &plain);
if (ret < 0)
{
gnutls_assert ();
@@ -160,20 +160,20 @@ _gnutls_decrypt (gnutls_session_t session, opaque *
ciphertext,
gcomp.data = data;
gcomp.size = ret;
- ret = _gnutls_m_compressed2plaintext (session, >xt, gcomp);
+ ret = _gnutls_m_compressed2plaintext (session, >xt, &gcomp);
if (ret < 0)
{
return ret;
}
- if (gtxt.size > max_data_size)
+ if (gtxt.size > MAX_RECORD_RECV_SIZE)
{
gnutls_assert ();
_gnutls_free_datum (>xt);
/* This shouldn't have happen and
* is a TLS fatal error.
*/
- return GNUTLS_E_INTERNAL_ERROR;
+ return GNUTLS_E_DECOMPRESSION_FAILED;
}
memcpy (data, gtxt.data, gtxt.size);
diff --git a/lib/gnutls_compress.c b/lib/gnutls_compress.c
index 9e42157..b2b8f87 100644
--- a/lib/gnutls_compress.c
+++ b/lib/gnutls_compress.c
@@ -36,15 +36,15 @@
int
_gnutls_m_plaintext2compressed (gnutls_session_t session,
gnutls_datum_t * compressed,
- gnutls_datum_t plaintext)
+ const gnutls_datum_t* plaintext)
{
int size;
opaque *data;
size =
_gnutls_compress (session->connection_state.write_compression_state,
- plaintext.data, plaintext.size, &data,
- MAX_RECORD_SEND_SIZE + 1024);
+ plaintext->data, plaintext->size, &data,
+ MAX_RECORD_SEND_SIZE + EXTRA_COMP_SIZE);
if (size < 0)
{
gnutls_assert ();
@@ -59,15 +59,15 @@ _gnutls_m_plaintext2compressed (gnutls_session_t session,
int
_gnutls_m_compressed2plaintext (gnutls_session_t session,
gnutls_datum_t * plain,
- gnutls_datum_t compressed)
+ const gnutls_datum_t* compressed)
{
int size;
opaque *data;
size =
_gnutls_decompress (session->connection_state.
- read_compression_state, compressed.data,
- compressed.size, &data, MAX_RECORD_RECV_SIZE);
+ read_compression_state, compressed->data,
+ compressed->size, &data, MAX_RECORD_RECV_SIZE);
if (size < 0)
{
gnutls_assert ();
diff --git a/lib/gnutls_compress.h b/lib/gnutls_compress.h
index 13e155e..fe42fea 100644
--- a/lib/gnutls_compress.h
+++ b/lib/gnutls_compress.h
@@ -24,7 +24,7 @@
int _gnutls_m_plaintext2compressed (gnutls_session_t session,
gnutls_datum_t * compressed,
- gnutls_datum_t plaintext);
+ const gnutls_datum_t *plaintext);
int _gnutls_m_compressed2plaintext (gnutls_session_t session,
gnutls_datum_t * plain,
- gnutls_datum_t compressed);
+ const gnutls_datum_t* compressed);
diff --git a/lib/gnutls_record.c b/lib/gnutls_record.c
index 990526e..5e3492c 100644
--- a/lib/gnutls_record.c
+++ b/lib/gnutls_record.c
@@ -777,13 +777,19 @@ record_check_type (gnutls_session_t session,
inline static int
get_temp_recv_buffer (gnutls_session_t session, gnutls_datum_t * tmp)
{
+size_t max_record_size;
+
+ if (gnutls_compression_get(session) != GNUTLS_COMP_NULL)
+ max_record_size = MAX_RECORD_RECV_SIZE + EXTRA_COMP_SIZE;
+ else
+ max_record_size = MAX_RECORD_RECV_SIZE;
/* We allocate MAX_RECORD_RECV_SIZE length
* because we cannot predict the output data by the record
* packet length (due to compression).
*/
- if (MAX_RECORD_RECV_SIZE > session->internals.recv_buffer.size ||
+ if (max_record_size > session->internals.recv_buffer.size ||
session->internals.recv_buffer.data == NULL)
{
@@ -791,7 +797,7 @@ get_temp_recv_buffer (gnutls_session_t session,
gnutls_datum_t * tmp)
*/
session->internals.recv_buffer.data =
gnutls_realloc (session->internals.recv_buffer.data,
- MAX_RECORD_RECV_SIZE);
+ max_record_size);
if (session->internals.recv_buffer.data == NULL)
{
@@ -799,7 +805,7 @@ get_temp_recv_buffer (gnutls_session_t session,
gnutls_datum_t * tmp)
return GNUTLS_E_MEMORY_ERROR;
}
- session->internals.recv_buffer.size = MAX_RECORD_RECV_SIZE;
+ session->internals.recv_buffer.size = max_record_size;
}
tmp->data = session->internals.recv_buffer.data;
- [gnutls-dev] GNUTLS_E_INTERNAL_ERROR in _gnutls_ciphertext2compressed, Tim Kosse, 2007/11/13
- Re: [gnutls-dev] GNUTLS_E_INTERNAL_ERROR in _gnutls_ciphertext2compressed, Ludovic Courtès, 2007/11/14
- Re: [gnutls-dev] GNUTLS_E_INTERNAL_ERROR in _gnutls_ciphertext2compressed, Nikos Mavrogiannopoulos, 2007/11/15
- Re: [gnutls-dev] GNUTLS_E_INTERNAL_ERROR in _gnutls_ciphertext2compressed,
Ludovic Courtès <=
- Re: [gnutls-dev] GNUTLS_E_INTERNAL_ERROR in _gnutls_ciphertext2compressed, Ludovic Courtès, 2007/11/15
- Re: [gnutls-dev] GNUTLS_E_INTERNAL_ERROR in _gnutls_ciphertext2compressed, Nikos Mavrogiannopoulos, 2007/11/15
- Re: [gnutls-dev] GNUTLS_E_INTERNAL_ERROR in _gnutls_ciphertext2compressed, Nikos Mavrogiannopoulos, 2007/11/15
- Re: [gnutls-dev] GNUTLS_E_INTERNAL_ERROR in _gnutls_ciphertext2compressed, Ludovic Courtès, 2007/11/15
- Re: [gnutls-dev] GNUTLS_E_INTERNAL_ERROR in _gnutls_ciphertext2compressed, Nikos Mavrogiannopoulos, 2007/11/15
- Re: [gnutls-dev] GNUTLS_E_INTERNAL_ERROR in _gnutls_ciphertext2compressed, Ludovic Courtès, 2007/11/16
- Re: [gnutls-dev] GNUTLS_E_INTERNAL_ERROR in _gnutls_ciphertext2compressed, Simon Josefsson, 2007/11/17
- Re: [gnutls-dev] GNUTLS_E_INTERNAL_ERROR in _gnutls_ciphertext2compressed, Nikos Mavrogiannopoulos, 2007/11/17
- Re: [gnutls-dev] GNUTLS_E_INTERNAL_ERROR in _gnutls_ciphertext2compressed, Ludovic Courtès, 2007/11/19