Fix error codes for memory-saving patch.
authorBodo Möller <bodo@openssl.org>
Mon, 4 Aug 2008 22:10:38 +0000 (22:10 +0000)
committerBodo Möller <bodo@openssl.org>
Mon, 4 Aug 2008 22:10:38 +0000 (22:10 +0000)
Also, get rid of compile-time switch OPENSSL_NO_RELEASE_BUFFERS
because it was rather pointless (the new behavior has to be explicitly
requested by setting SSL_MODE_RELEASE_BUFFERS anyway).

ssl/s3_both.c
ssl/s3_pkt.c
ssl/ssl.h
ssl/ssl_err.c
ssl/ssl_lib.c
ssl/ssl_locl.h

index 88bed0fa6bea5314aaed7c17cfb5635d5cd95b38..06e761b4b276294a5b8a5b885b08081f99097854 100644 (file)
@@ -591,7 +591,7 @@ int ssl_verify_alarm_type(long type)
        return(al);
        }
 
-#if !defined(OPENSSL_NO_BUF_FREELISTS) && !defined(OPENSSL_NO_RELEASE_BUFFERS)
+#ifndef OPENSSL_NO_BUF_FREELISTS
 /* On some platforms, malloc() performance is bad enough that you can't just
  * free() and malloc() buffers all the time, so we need to use freelists from
  * unused buffers.  Currently, each freelist holds memory chunks of only a
@@ -698,7 +698,7 @@ int ssl3_setup_read_buffer(SSL *s)
        return 1;
 
 err:
-       SSLerr(SSL_F_SSL3_SETUP_BUFFERS,ERR_R_MALLOC_FAILURE);
+       SSLerr(SSL_F_SSL3_SETUP_READ_BUFFER,ERR_R_MALLOC_FAILURE);
        return 0;
        }
 
@@ -733,7 +733,7 @@ int ssl3_setup_write_buffer(SSL *s)
        return 1;
 
 err:
-       SSLerr(SSL_F_SSL3_SETUP_BUFFERS,ERR_R_MALLOC_FAILURE);
+       SSLerr(SSL_F_SSL3_SETUP_WRITE_BUFFER,ERR_R_MALLOC_FAILURE);
        return 0;
        }
 
index b4a1629853afbe9eb9a6959800ec95893dd968f7..07dd4b23d5204b6840c2b01e4af48d449ebafe76 100644 (file)
@@ -238,11 +238,9 @@ int ssl3_read_n(SSL *s, int n, int max, int extend)
                if (i <= 0)
                        {
                        rb->left = left;
-#ifndef OPENSSL_NO_RELEASE_BUFFERS
-                       if (len+left == 0 &&
-                           (s->mode & SSL_MODE_RELEASE_BUFFERS))
-                               ssl3_release_read_buffer(s);
-#endif
+                       if (s->mode & SSL_MODE_RELEASE_BUFFERS)
+                               if (len+left == 0)
+                                       ssl3_release_read_buffer(s);
                        return(i);
                        }
                left+=i;
@@ -825,10 +823,8 @@ int ssl3_write_pending(SSL *s, int type, const unsigned char *buf,
                        {
                        wb->left=0;
                        wb->offset+=i;
-#ifndef OPENSSL_NO_RELEASE_BUFFERS
                        if (s->mode & SSL_MODE_RELEASE_BUFFERS)
                                ssl3_release_write_buffer(s);
-#endif
                        s->rwstate=SSL_NOTHING;
                        return(s->s3->wpend_ret);
                        }
@@ -983,10 +979,8 @@ start:
                                {
                                s->rstate=SSL_ST_READ_HEADER;
                                rr->off=0;
-#ifndef OPENSSL_NO_RELEASE_BUFFERS
-                               if ((s->mode & SSL_MODE_RELEASE_BUFFERS))
+                               if (s->mode & SSL_MODE_RELEASE_BUFFERS)
                                        ssl3_release_read_buffer(s);
-#endif
                                }
                        }
                return(n);
index da105e940c51eaa8c75b37564569f84f2d6bb43c..af6702030b38672267f22c8ad1b45781e047fdbd 100644 (file)
--- a/ssl/ssl.h
+++ b/ssl/ssl.h
@@ -840,7 +840,7 @@ struct ssl_ctx_st
                unsigned char *psk, unsigned int max_psk_len);
 #endif
 
-#if !defined(OPENSSL_NO_BUF_FREELISTS) || !defined(OPENSSL_NO_RELEASE_BUFFERS)
+#ifndef OPENSSL_NO_BUF_FREELISTS
 #define SSL_MAX_BUF_FREELIST_LEN_DEFAULT 32
        unsigned int freelist_max_len;
        struct ssl3_buf_freelist_st *wbuf_freelist;
@@ -1851,8 +1851,9 @@ void ERR_load_SSL_strings(void);
 #define SSL_F_SSL3_SEND_SERVER_CERTIFICATE              154
 #define SSL_F_SSL3_SEND_SERVER_HELLO                    242
 #define SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE             155
-#define SSL_F_SSL3_SETUP_BUFFERS                        156
 #define SSL_F_SSL3_SETUP_KEY_BLOCK                      157
+#define SSL_F_SSL3_SETUP_READ_BUFFER                    156
+#define SSL_F_SSL3_SETUP_WRITE_BUFFER                   291
 #define SSL_F_SSL3_WRITE_BYTES                          158
 #define SSL_F_SSL3_WRITE_PENDING                        159
 #define SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT                277
index 21fcd3fd442309602ab6a770301302b75bb77ecf..a93cc4c6741c9a012b39571e3bc73d76ea4db373 100644 (file)
@@ -1,6 +1,6 @@
 /* ssl/ssl_err.c */
 /* ====================================================================
- * Copyright (c) 1999-2007 The OpenSSL Project.  All rights reserved.
+ * Copyright (c) 1999-2008 The OpenSSL Project.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -167,8 +167,9 @@ static ERR_STRING_DATA SSL_str_functs[]=
 {ERR_FUNC(SSL_F_SSL3_SEND_SERVER_CERTIFICATE), "SSL3_SEND_SERVER_CERTIFICATE"},
 {ERR_FUNC(SSL_F_SSL3_SEND_SERVER_HELLO),       "SSL3_SEND_SERVER_HELLO"},
 {ERR_FUNC(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE),        "SSL3_SEND_SERVER_KEY_EXCHANGE"},
-{ERR_FUNC(SSL_F_SSL3_SETUP_BUFFERS),   "SSL3_SETUP_BUFFERS"},
 {ERR_FUNC(SSL_F_SSL3_SETUP_KEY_BLOCK), "SSL3_SETUP_KEY_BLOCK"},
+{ERR_FUNC(SSL_F_SSL3_SETUP_READ_BUFFER),       "SSL3_SETUP_READ_BUFFER"},
+{ERR_FUNC(SSL_F_SSL3_SETUP_WRITE_BUFFER),      "SSL3_SETUP_WRITE_BUFFER"},
 {ERR_FUNC(SSL_F_SSL3_WRITE_BYTES),     "SSL3_WRITE_BYTES"},
 {ERR_FUNC(SSL_F_SSL3_WRITE_PENDING),   "SSL3_WRITE_PENDING"},
 {ERR_FUNC(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT),   "SSL_ADD_CLIENTHELLO_TLSEXT"},
index 736423fd154106c16d1e5a12fffce0c7c6900e87..203bce661a97fe398761fdfceb97db0222da4f7d 100644 (file)
@@ -1581,7 +1581,7 @@ SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth)
        ret->psk_client_callback=NULL;
        ret->psk_server_callback=NULL;
 #endif
-#if !defined(OPENSSL_NO_BUF_FREELISTS) && !defined(OPENSSL_NO_RELEASE_BUFFERS)
+#ifndef OPENSSL_NO_BUF_FREELISTS
        ret->freelist_max_len = SSL_MAX_BUF_FREELIST_LEN_DEFAULT;
        ret->rbuf_freelist = OPENSSL_malloc(sizeof(SSL3_BUF_FREELIST));
        if (!ret->rbuf_freelist)
@@ -1633,7 +1633,7 @@ static void SSL_COMP_free(SSL_COMP *comp)
     { OPENSSL_free(comp); }
 #endif
 
-#if !defined(OPENSSL_NO_BUF_FREELISTS) && !defined(OPENSSL_NO_RELEASE_BUFFERS)
+#ifndef OPENSSL_NO_BUF_FREELISTS
 static void
 ssl_buf_freelist_free(SSL3_BUF_FREELIST *list)
        {
@@ -1714,7 +1714,7 @@ void SSL_CTX_free(SSL_CTX *a)
                ENGINE_finish(a->client_cert_engine);
 #endif
 
-#if !defined(OPENSSL_NO_BUF_FREELISTS) && !defined(OPENSSL_NO_RELEASE_BUFFERS)
+#ifndef OPENSSL_NO_BUF_FREELISTS
        if (a->wbuf_freelist)
                ssl_buf_freelist_free(a->wbuf_freelist);
        if (a->rbuf_freelist)
index e3cb05e2f6b4e0dc9125704cc707769fc52c21d3..fc77fd0bde4de214b67a11f4acb72a1825fe992d 100644 (file)
@@ -561,7 +561,7 @@ typedef struct ssl3_comp_st
        COMP_METHOD *method; /* The method :-) */
        } SSL3_COMP;
 
-#if !defined(OPENSSL_NO_BUF_FREELISTS) && !defined(OPENSSL_NO_RELEASE_BUFFERS)
+#ifndef OPENSSL_NO_BUF_FREELISTS
 typedef struct ssl3_buf_freelist_st
        {
        size_t chunklen;