X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=crypto%2Fbio%2Fbio_lib.c;h=381afc9b8e03a05d5e8b3459e5a3d9facc4b5055;hb=7d09713d09f41778c92913d57a877a4eb1aebbfc;hp=00163f21bd35ebc72161f4912901b7ad7749c4dd;hpb=0e1c06128adbfd2d88dc304db2262140bad045fd;p=oweals%2Fopenssl.git diff --git a/crypto/bio/bio_lib.c b/crypto/bio/bio_lib.c index 00163f21bd..381afc9b8e 100644 --- a/crypto/bio/bio_lib.c +++ b/crypto/bio/bio_lib.c @@ -70,7 +70,7 @@ BIO *BIO_new(BIO_METHOD *method) { BIO *ret=NULL; - ret=(BIO *)Malloc(sizeof(BIO)); + ret=(BIO *)OPENSSL_malloc(sizeof(BIO)); if (ret == NULL) { BIOerr(BIO_F_BIO_NEW,ERR_R_MALLOC_FAILURE); @@ -78,7 +78,7 @@ BIO *BIO_new(BIO_METHOD *method) } if (!BIO_set(ret,method)) { - Free(ret); + OPENSSL_free(ret); ret=NULL; } return(ret); @@ -133,10 +133,13 @@ int BIO_free(BIO *a) if ((a->method == NULL) || (a->method->destroy == NULL)) return(1); ret=a->method->destroy(a); - Free(a); + OPENSSL_free(a); return(1); } +void BIO_vfree(BIO *a) + { BIO_free(a); } + int BIO_read(BIO *b, void *out, int outl) { int i; @@ -198,13 +201,7 @@ int BIO_write(BIO *b, const void *in, int inl) if (i > 0) b->num_write+=(unsigned long)i; - /* This is evil and not thread safe. If the BIO has been freed, - * we must not call the callback. The only way to be able to - * determine this is the reference count which is now invalid since - * the memory has been free()ed. - */ - if (b->references <= 0) abort(); - if (cb != NULL) /* && (b->references >= 1)) */ + if (cb != NULL) i=(int)cb(b,BIO_CB_WRITE|BIO_CB_RETURN,in,inl, 0L,(long)i); return(i); @@ -235,6 +232,8 @@ int BIO_puts(BIO *b, const char *in) i=b->method->bputs(b,in); + if (i > 0) b->num_write+=(unsigned long)i; + if (cb != NULL) i=(int)cb(b,BIO_CB_PUTS|BIO_CB_RETURN,in,0, 0L,(long)i); @@ -419,6 +418,7 @@ BIO *BIO_find_type(BIO *bio, int type) { int mt,mask; + if(!bio) return NULL; mask=type&0xff; do { if (bio->method != NULL) @@ -437,6 +437,12 @@ BIO *BIO_find_type(BIO *bio, int type) return(NULL); } +BIO *BIO_next(BIO *b) + { + if(!b) return NULL; + return b->next_bio; + } + void BIO_free_all(BIO *bio) { BIO *b; @@ -532,3 +538,5 @@ unsigned long BIO_number_written(BIO *bio) if(bio) return bio->num_write; return 0; } + +IMPLEMENT_STACK_OF(BIO)