From 2a00e489122f6c4b525090dbdba2855a2ea2d519 Mon Sep 17 00:00:00 2001 From: marha Date: Mon, 20 Apr 2015 22:51:55 +0200 Subject: Upgraded to openssl 1.0.2a --- openssl/crypto/bio/b_print.c | 15 ++++++++++----- openssl/crypto/bio/bio.h | 1 + openssl/crypto/bio/bio_cb.c | 9 ++++++--- openssl/crypto/bio/bio_err.c | 3 ++- openssl/crypto/bio/bss_dgram.c | 15 ++++++++++++++- 5 files changed, 33 insertions(+), 10 deletions(-) (limited to 'openssl/crypto/bio') diff --git a/openssl/crypto/bio/b_print.c b/openssl/crypto/bio/b_print.c index 5dc763000..c2cf6e619 100644 --- a/openssl/crypto/bio/b_print.c +++ b/openssl/crypto/bio/b_print.c @@ -592,7 +592,6 @@ fmtfp(char **sbuffer, int fplace = 0; int padlen = 0; int zpadlen = 0; - int caps = 0; long intpart; long fracpart; long max10; @@ -630,8 +629,7 @@ fmtfp(char **sbuffer, /* convert integer part */ do { - iconvert[iplace++] = - (caps ? "0123456789ABCDEF" : "0123456789abcdef")[intpart % 10]; + iconvert[iplace++] = "0123456789"[intpart % 10]; intpart = (intpart / 10); } while (intpart && (iplace < (int)sizeof(iconvert))); if (iplace == sizeof iconvert) @@ -640,8 +638,7 @@ fmtfp(char **sbuffer, /* convert fractional part */ do { - fconvert[fplace++] = - (caps ? "0123456789ABCDEF" : "0123456789abcdef")[fracpart % 10]; + fconvert[fplace++] = "0123456789"[fracpart % 10]; fracpart = (fracpart / 10); } while (fplace < max); if (fplace == sizeof fconvert) @@ -713,6 +710,10 @@ doapr_outch(char **sbuffer, if (*maxlen == 0) *maxlen = 1024; *buffer = OPENSSL_malloc(*maxlen); + if(!*buffer) { + /* Panic! Can't really do anything sensible. Just return */ + return; + } if (*currlen > 0) { assert(*sbuffer != NULL); memcpy(*buffer, *sbuffer, *currlen); @@ -721,6 +722,10 @@ doapr_outch(char **sbuffer, } else { *maxlen += 1024; *buffer = OPENSSL_realloc(*buffer, *maxlen); + if(!*buffer) { + /* Panic! Can't really do anything sensible. Just return */ + return; + } } } /* What to do if *buffer is NULL? */ diff --git a/openssl/crypto/bio/bio.h b/openssl/crypto/bio/bio.h index 60083bfde..7878fb198 100644 --- a/openssl/crypto/bio/bio.h +++ b/openssl/crypto/bio/bio.h @@ -833,6 +833,7 @@ void ERR_load_BIO_strings(void); # define BIO_F_CONN_CTRL 127 # define BIO_F_CONN_STATE 115 # define BIO_F_DGRAM_SCTP_READ 132 +# define BIO_F_DGRAM_SCTP_WRITE 133 # define BIO_F_FILE_CTRL 116 # define BIO_F_FILE_READ 130 # define BIO_F_LINEBUFFER_CTRL 129 diff --git a/openssl/crypto/bio/bio_cb.c b/openssl/crypto/bio/bio_cb.c index 8715f5cbc..d3e860686 100644 --- a/openssl/crypto/bio/bio_cb.c +++ b/openssl/crypto/bio/bio_cb.c @@ -70,14 +70,17 @@ long MS_CALLBACK BIO_debug_callback(BIO *bio, int cmd, const char *argp, MS_STATIC char buf[256]; char *p; long r = 1; + int len; size_t p_maxlen; if (BIO_CB_RETURN & cmd) r = ret; - BIO_snprintf(buf, sizeof buf, "BIO[%08lX]:", (unsigned long)bio); - p = &(buf[14]); - p_maxlen = sizeof buf - 14; + len = BIO_snprintf(buf,sizeof buf,"BIO[%p]: ",(void *)bio); + + p = buf + len; + p_maxlen = sizeof(buf) - len; + switch (cmd) { case BIO_CB_FREE: BIO_snprintf(p, p_maxlen, "Free - %s\n", bio->method->name); diff --git a/openssl/crypto/bio/bio_err.c b/openssl/crypto/bio/bio_err.c index e8d3027c6..d9007aa3d 100644 --- a/openssl/crypto/bio/bio_err.c +++ b/openssl/crypto/bio/bio_err.c @@ -1,6 +1,6 @@ /* crypto/bio/bio_err.c */ /* ==================================================================== - * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. + * Copyright (c) 1999-2015 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 @@ -96,6 +96,7 @@ static ERR_STRING_DATA BIO_str_functs[] = { {ERR_FUNC(BIO_F_CONN_CTRL), "CONN_CTRL"}, {ERR_FUNC(BIO_F_CONN_STATE), "CONN_STATE"}, {ERR_FUNC(BIO_F_DGRAM_SCTP_READ), "DGRAM_SCTP_READ"}, + {ERR_FUNC(BIO_F_DGRAM_SCTP_WRITE), "DGRAM_SCTP_WRITE"}, {ERR_FUNC(BIO_F_FILE_CTRL), "FILE_CTRL"}, {ERR_FUNC(BIO_F_FILE_READ), "FILE_READ"}, {ERR_FUNC(BIO_F_LINEBUFFER_CTRL), "LINEBUFFER_CTRL"}, diff --git a/openssl/crypto/bio/bss_dgram.c b/openssl/crypto/bio/bss_dgram.c index fcbae5f74..388d90d02 100644 --- a/openssl/crypto/bio/bss_dgram.c +++ b/openssl/crypto/bio/bss_dgram.c @@ -1012,6 +1012,10 @@ BIO *BIO_new_dgram_sctp(int fd, int close_flag) */ sockopt_len = (socklen_t) (sizeof(sctp_assoc_t) + 256 * sizeof(uint8_t)); authchunks = OPENSSL_malloc(sockopt_len); + if(!authchunks) { + BIO_vfree(bio); + return (NULL); + } memset(authchunks, 0, sizeof(sockopt_len)); ret = getsockopt(fd, IPPROTO_SCTP, SCTP_LOCAL_AUTH_CHUNKS, authchunks, @@ -1347,6 +1351,10 @@ static int dgram_sctp_read(BIO *b, char *out, int outl) optlen = (socklen_t) (sizeof(sctp_assoc_t) + 256 * sizeof(uint8_t)); authchunks = OPENSSL_malloc(optlen); + if (!authchunks) { + BIOerr(BIO_F_DGRAM_SCTP_READ, ERR_R_MALLOC_ERROR); + return -1; + } memset(authchunks, 0, sizeof(optlen)); ii = getsockopt(b->num, IPPROTO_SCTP, SCTP_PEER_AUTH_CHUNKS, authchunks, &optlen); @@ -1413,10 +1421,15 @@ static int dgram_sctp_write(BIO *b, const char *in, int inl) * yet, we have to save it and send it as soon as the socket gets dry. */ if (data->save_shutdown && !BIO_dgram_sctp_wait_for_dry(b)) { + char *tmp; data->saved_message.bio = b; + if(!(tmp = OPENSSL_malloc(inl))) { + BIOerr(BIO_F_DGRAM_SCTP_WRITE, ERR_R_MALLOC_ERROR); + return -1; + } if (data->saved_message.data) OPENSSL_free(data->saved_message.data); - data->saved_message.data = OPENSSL_malloc(inl); + data->saved_message.data = tmp; memcpy(data->saved_message.data, in, inl); data->saved_message.length = inl; return inl; -- cgit v1.2.3