Bugfixes provided by "Stephen Hinton" <shinton@netopia.com>.
[openssl.git] / crypto / bio / bss_bio.c
index 1e2d7491f2ca7bbdc355e772196d8f91166212f5..f666c47f4e17258dbcd871c15f4f563e76813c8c 100644 (file)
@@ -22,7 +22,7 @@
 #include <openssl/err.h>
 #include <openssl/crypto.h>
 
-#include "openssl/e_os.h"
+#include "e_os.h"
 #ifndef SSIZE_MAX
 # define SSIZE_MAX INT_MAX
 #endif
@@ -30,9 +30,9 @@
 static int bio_new(BIO *bio);
 static int bio_free(BIO *bio);
 static int bio_read(BIO *bio, char *buf, int size);
-static int bio_write(BIO *bio, char *buf, int num);
+static int bio_write(BIO *bio, const char *buf, int num);
 static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr);
-static int bio_puts(BIO *bio, char *str);
+static int bio_puts(BIO *bio, const char *str);
 
 static int bio_make_pair(BIO *bio1, BIO *bio2);
 static void bio_destroy_pair(BIO *bio);
@@ -80,7 +80,7 @@ static int bio_new(BIO *bio)
        {
        struct bio_bio_st *b;
        
-       b = Malloc(sizeof *b);
+       b = OPENSSL_malloc(sizeof *b);
        if (b == NULL)
                return 0;
 
@@ -108,10 +108,10 @@ static int bio_free(BIO *bio)
        
        if (b->buf != NULL)
                {
-               Free(b->buf);
+               OPENSSL_free(b->buf);
                }
 
-       Free(b);
+       OPENSSL_free(b);
 
        return 1;
        }
@@ -283,7 +283,7 @@ static ssize_t bio_nread(BIO *bio, char **buf, size_t num_)
        }
 
 
-static int bio_write(BIO *bio, char *buf, int num_)
+static int bio_write(BIO *bio, const char *buf, int num_)
        {
        size_t num = num_;
        size_t rest;
@@ -464,7 +464,7 @@ static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr)
                                {
                                if (b->buf) 
                                        {
-                                       Free(b->buf);
+                                       OPENSSL_free(b->buf);
                                        b->buf = NULL;
                                        }
                                b->size = new_size;
@@ -474,7 +474,8 @@ static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr)
                break;
 
        case BIO_C_GET_WRITE_BUF_SIZE:
-               num = (long) b->size;
+               ret = (long) b->size;
+               break;
 
        case BIO_C_MAKE_BIO_PAIR:
                {
@@ -628,7 +629,7 @@ static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr)
        return ret;
        }
 
-static int bio_puts(BIO *bio, char *str)
+static int bio_puts(BIO *bio, const char *str)
        {
        return bio_write(bio, str, strlen(str));
        }
@@ -652,7 +653,7 @@ static int bio_make_pair(BIO *bio1, BIO *bio2)
        
        if (b1->buf == NULL)
                {
-               b1->buf = Malloc(b1->size);
+               b1->buf = OPENSSL_malloc(b1->size);
                if (b1->buf == NULL)
                        {
                        BIOerr(BIO_F_BIO_MAKE_PAIR, ERR_R_MALLOC_FAILURE);
@@ -664,7 +665,7 @@ static int bio_make_pair(BIO *bio1, BIO *bio2)
        
        if (b2->buf == NULL)
                {
-               b2->buf = Malloc(b2->size);
+               b2->buf = OPENSSL_malloc(b2->size);
                if (b2->buf == NULL)
                        {
                        BIOerr(BIO_F_BIO_MAKE_PAIR, ERR_R_MALLOC_FAILURE);