]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
changes in gnutls_encrypt()
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Thu, 25 Jan 2001 02:11:29 +0000 (02:11 +0000)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Thu, 25 Jan 2001 02:11:29 +0000 (02:11 +0000)
lib/gnutls_cipher.c
lib/gnutls_cipher.h

index 30f9d628ffe30611840f1089808f74f2a49485fe..52a0460ce0f9d72103ab86f1f374b608eebe2b9d 100644 (file)
@@ -30,7 +30,7 @@
 #include "debug.h"
 
 int _gnutls_encrypt(GNUTLS_STATE state, char *data, size_t data_size,
-                   uint8 ** ciphertext, ContentType type)
+                   uint8 * ciphertext, ContentType type)
 {
        GNUTLSPlaintext *gtxt;
        GNUTLSCompressed *gcomp;
@@ -63,13 +63,17 @@ int _gnutls_encrypt(GNUTLS_STATE state, char *data, size_t data_size,
 
        _gnutls_freeTLSCompressed(gcomp);
 
-       *ciphertext = gnutls_malloc(gcipher->length);
-       if (*ciphertext == NULL) {
+       if (ciphertext == NULL) {
                gnutls_assert();
                return GNUTLS_E_MEMORY_ERROR;
        }
-       memmove((*ciphertext), gcipher->fragment, gcipher->length);
-
+       if (gcipher->length < MAX_ENC_LEN)
+               memmove(ciphertext, gcipher->fragment, gcipher->length);
+       else {
+               /* that shouldn't happen! */
+               gnutls_assert();
+               return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
+       }
 
        total_length += gcipher->length;
        _gnutls_freeTLSCiphertext(gcipher);
index dc0ed1d44518bf532e5c7691458c3411701f83b2..daf0563804863c17d80321468415417f95d68438 100644 (file)
@@ -1,4 +1,4 @@
-int _gnutls_encrypt( GNUTLS_STATE state, char* data, size_t data_size, uint8** ciphertext, ContentType type);
+int _gnutls_encrypt( GNUTLS_STATE state, char* data, size_t data_size, uint8* ciphertext, ContentType type);
 int _gnutls_decrypt(GNUTLS_STATE state, char *ciphertext,
                    size_t ciphertext_size, uint8 ** data,
                    ContentType type);