From 79e8bed4724e7275dedb82244ce78fabd6d5bcfa Mon Sep 17 00:00:00 2001 From: jsing Date: Thu, 17 Apr 2014 13:58:24 +0000 Subject: [PATCH] Initial KNF. --- lib/libcrypto/buffer/buf_err.c | 45 +++--- lib/libcrypto/buffer/buffer.c | 195 ++++++++++++------------- lib/libcrypto/buffer/buffer.h | 21 ++- lib/libssl/src/crypto/buffer/buf_err.c | 45 +++--- lib/libssl/src/crypto/buffer/buffer.c | 195 ++++++++++++------------- lib/libssl/src/crypto/buffer/buffer.h | 21 ++- 6 files changed, 244 insertions(+), 278 deletions(-) diff --git a/lib/libcrypto/buffer/buf_err.c b/lib/libcrypto/buffer/buf_err.c index 8f1de6192be..4e1949199a8 100644 --- a/lib/libcrypto/buffer/buf_err.c +++ b/lib/libcrypto/buffer/buf_err.c @@ -7,7 +7,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -68,32 +68,29 @@ #define ERR_FUNC(func) ERR_PACK(ERR_LIB_BUF,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_BUF,0,reason) -static ERR_STRING_DATA BUF_str_functs[]= - { -{ERR_FUNC(BUF_F_BUF_MEMDUP), "BUF_memdup"}, -{ERR_FUNC(BUF_F_BUF_MEM_GROW), "BUF_MEM_grow"}, -{ERR_FUNC(BUF_F_BUF_MEM_GROW_CLEAN), "BUF_MEM_grow_clean"}, -{ERR_FUNC(BUF_F_BUF_MEM_NEW), "BUF_MEM_new"}, -{ERR_FUNC(BUF_F_BUF_STRDUP), "BUF_strdup"}, -{ERR_FUNC(BUF_F_BUF_STRNDUP), "BUF_strndup"}, -{0,NULL} - }; +static ERR_STRING_DATA BUF_str_functs[] = { + {ERR_FUNC(BUF_F_BUF_MEMDUP), "BUF_memdup"}, + {ERR_FUNC(BUF_F_BUF_MEM_GROW), "BUF_MEM_grow"}, + {ERR_FUNC(BUF_F_BUF_MEM_GROW_CLEAN), "BUF_MEM_grow_clean"}, + {ERR_FUNC(BUF_F_BUF_MEM_NEW), "BUF_MEM_new"}, + {ERR_FUNC(BUF_F_BUF_STRDUP), "BUF_strdup"}, + {ERR_FUNC(BUF_F_BUF_STRNDUP), "BUF_strndup"}, + {0, NULL} +}; -static ERR_STRING_DATA BUF_str_reasons[]= - { -{0,NULL} - }; +static ERR_STRING_DATA BUF_str_reasons[] = { + {0, NULL} +}; #endif -void ERR_load_BUF_strings(void) - { +void +ERR_load_BUF_strings(void) +{ #ifndef OPENSSL_NO_ERR - - if (ERR_func_error_string(BUF_str_functs[0].error) == NULL) - { - ERR_load_strings(0,BUF_str_functs); - ERR_load_strings(0,BUF_str_reasons); - } -#endif + if (ERR_func_error_string(BUF_str_functs[0].error) == NULL) { + ERR_load_strings(0, BUF_str_functs); + ERR_load_strings(0, BUF_str_reasons); } +#endif +} diff --git a/lib/libcrypto/buffer/buffer.c b/lib/libcrypto/buffer/buffer.c index b52c59f8a31..4bd55c04ae5 100644 --- a/lib/libcrypto/buffer/buffer.c +++ b/lib/libcrypto/buffer/buffer.c @@ -5,21 +5,21 @@ * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. - * + * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * + * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -34,10 +34,10 @@ * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from + * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * + * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -49,7 +49,7 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * + * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence @@ -65,139 +65,126 @@ * that the result fits in an int. */ #define LIMIT_BEFORE_EXPANSION 0x5ffffffc -BUF_MEM *BUF_MEM_new(void) - { +BUF_MEM * +BUF_MEM_new(void) +{ BUF_MEM *ret; - ret=malloc(sizeof(BUF_MEM)); - if (ret == NULL) - { - BUFerr(BUF_F_BUF_MEM_NEW,ERR_R_MALLOC_FAILURE); - return(NULL); - } - ret->length=0; - ret->max=0; - ret->data=NULL; - return(ret); + ret = malloc(sizeof(BUF_MEM)); + if (ret == NULL) { + BUFerr(BUF_F_BUF_MEM_NEW, ERR_R_MALLOC_FAILURE); + return (NULL); } + ret->length = 0; + ret->max = 0; + ret->data = NULL; + return (ret); +} -void BUF_MEM_free(BUF_MEM *a) - { - if(a == NULL) - return; +void +BUF_MEM_free(BUF_MEM *a) +{ + if (a == NULL) + return; - if (a->data != NULL) - { - memset(a->data,0,(unsigned int)a->max); + if (a->data != NULL) { + memset(a->data, 0,(unsigned int)a->max); free(a->data); - } - free(a); } + free(a); +} -int BUF_MEM_grow(BUF_MEM *str, size_t len) - { +int +BUF_MEM_grow(BUF_MEM *str, size_t len) +{ char *ret; size_t n; - if (str->length >= len) - { - str->length=len; - return(len); - } - if (str->max >= len) - { - memset(&str->data[str->length],0,len-str->length); - str->length=len; - return(len); - } + if (str->length >= len) { + str->length = len; + return (len); + } + if (str->max >= len) { + memset(&str->data[str->length], 0,len - str->length); + str->length = len; + return (len); + } /* This limit is sufficient to ensure (len+3)/3*4 < 2**31 */ - if (len > LIMIT_BEFORE_EXPANSION) - { - BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE); + if (len > LIMIT_BEFORE_EXPANSION) { + BUFerr(BUF_F_BUF_MEM_GROW, ERR_R_MALLOC_FAILURE); return 0; - } - n=(len+3)/3*4; + } + n = (len + 3) / 3 * 4; if (str->data == NULL) - ret=malloc(n); + ret = malloc(n); else - ret=realloc(str->data,n); - if (ret == NULL) - { - BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE); - len=0; - } - else - { - str->data=ret; - str->max=n; - memset(&str->data[str->length],0,len-str->length); - str->length=len; - } - return(len); + ret = realloc(str->data, n); + if (ret == NULL) { + BUFerr(BUF_F_BUF_MEM_GROW, ERR_R_MALLOC_FAILURE); + len = 0; + } else { + str->data = ret; + str->max = n; + memset(&str->data[str->length], 0,len - str->length); + str->length = len; } + return (len); +} -int BUF_MEM_grow_clean(BUF_MEM *str, size_t len) - { +int +BUF_MEM_grow_clean(BUF_MEM *str, size_t len) +{ char *ret; size_t n; - if (str->length >= len) - { - memset(&str->data[len],0,str->length-len); - str->length=len; - return(len); - } - if (str->max >= len) - { - memset(&str->data[str->length],0,len-str->length); - str->length=len; - return(len); - } + if (str->length >= len) { + memset(&str->data[len], 0,str->length - len); + str->length = len; + return (len); + } + if (str->max >= len) { + memset(&str->data[str->length], 0,len - str->length); + str->length = len; + return (len); + } /* This limit is sufficient to ensure (len+3)/3*4 < 2**31 */ - if (len > LIMIT_BEFORE_EXPANSION) - { - BUFerr(BUF_F_BUF_MEM_GROW_CLEAN,ERR_R_MALLOC_FAILURE); + if (len > LIMIT_BEFORE_EXPANSION) { + BUFerr(BUF_F_BUF_MEM_GROW_CLEAN, ERR_R_MALLOC_FAILURE); return 0; - } - n=(len+3)/3*4; + } + n = (len + 3) / 3 * 4; if (str->data == NULL) - ret=malloc(n); - else - ret=OPENSSL_realloc_clean(str->data,str->max,n); - if (ret == NULL) - { - BUFerr(BUF_F_BUF_MEM_GROW_CLEAN,ERR_R_MALLOC_FAILURE); - len=0; - } + ret = malloc(n); else - { - str->data=ret; - str->max=n; - memset(&str->data[str->length],0,len-str->length); - str->length=len; - } - return(len); + ret = OPENSSL_realloc_clean(str->data, str->max, n); + if (ret == NULL) { + BUFerr(BUF_F_BUF_MEM_GROW_CLEAN, ERR_R_MALLOC_FAILURE); + len = 0; + } else { + str->data = ret; + str->max = n; + memset(&str->data[str->length], 0, len - str->length); + str->length = len; } + return (len); +} -void BUF_reverse(unsigned char *out, const unsigned char *in, size_t size) - { +void +BUF_reverse(unsigned char *out, const unsigned char *in, size_t size) +{ size_t i; - if (in) - { + if (in) { out += size - 1; for (i = 0; i < size; i++) *out-- = *in++; - } - else - { + } else { unsigned char *q; char c; q = out + size - 1; - for (i = 0; i < size/2; i++) - { + for (i = 0; i < size / 2; i++) { c = *q; *q-- = *out; *out++ = c; - } } } +} diff --git a/lib/libcrypto/buffer/buffer.h b/lib/libcrypto/buffer/buffer.h index f8da32b4850..ab1fab44100 100644 --- a/lib/libcrypto/buffer/buffer.h +++ b/lib/libcrypto/buffer/buffer.h @@ -5,21 +5,21 @@ * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. - * + * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * + * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -34,10 +34,10 @@ * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from + * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * + * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -49,7 +49,7 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * + * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence @@ -74,12 +74,11 @@ extern "C" { /* Already declared in ossl_typ.h */ /* typedef struct buf_mem_st BUF_MEM; */ -struct buf_mem_st - { +struct buf_mem_st { size_t length; /* current number of bytes */ char *data; size_t max; /* size of buffer */ - }; +}; BUF_MEM *BUF_MEM_new(void); void BUF_MEM_free(BUF_MEM *a); @@ -91,8 +90,8 @@ void * BUF_memdup(const void *data, size_t siz); void BUF_reverse(unsigned char *out, const unsigned char *in, size_t siz); /* safe string functions */ -size_t BUF_strlcpy(char *dst,const char *src,size_t siz); -size_t BUF_strlcat(char *dst,const char *src,size_t siz); +size_t BUF_strlcpy(char *dst, const char *src, size_t siz); +size_t BUF_strlcat(char *dst, const char *src, size_t siz); /* BEGIN ERROR CODES */ diff --git a/lib/libssl/src/crypto/buffer/buf_err.c b/lib/libssl/src/crypto/buffer/buf_err.c index 8f1de6192be..4e1949199a8 100644 --- a/lib/libssl/src/crypto/buffer/buf_err.c +++ b/lib/libssl/src/crypto/buffer/buf_err.c @@ -7,7 +7,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -68,32 +68,29 @@ #define ERR_FUNC(func) ERR_PACK(ERR_LIB_BUF,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_BUF,0,reason) -static ERR_STRING_DATA BUF_str_functs[]= - { -{ERR_FUNC(BUF_F_BUF_MEMDUP), "BUF_memdup"}, -{ERR_FUNC(BUF_F_BUF_MEM_GROW), "BUF_MEM_grow"}, -{ERR_FUNC(BUF_F_BUF_MEM_GROW_CLEAN), "BUF_MEM_grow_clean"}, -{ERR_FUNC(BUF_F_BUF_MEM_NEW), "BUF_MEM_new"}, -{ERR_FUNC(BUF_F_BUF_STRDUP), "BUF_strdup"}, -{ERR_FUNC(BUF_F_BUF_STRNDUP), "BUF_strndup"}, -{0,NULL} - }; +static ERR_STRING_DATA BUF_str_functs[] = { + {ERR_FUNC(BUF_F_BUF_MEMDUP), "BUF_memdup"}, + {ERR_FUNC(BUF_F_BUF_MEM_GROW), "BUF_MEM_grow"}, + {ERR_FUNC(BUF_F_BUF_MEM_GROW_CLEAN), "BUF_MEM_grow_clean"}, + {ERR_FUNC(BUF_F_BUF_MEM_NEW), "BUF_MEM_new"}, + {ERR_FUNC(BUF_F_BUF_STRDUP), "BUF_strdup"}, + {ERR_FUNC(BUF_F_BUF_STRNDUP), "BUF_strndup"}, + {0, NULL} +}; -static ERR_STRING_DATA BUF_str_reasons[]= - { -{0,NULL} - }; +static ERR_STRING_DATA BUF_str_reasons[] = { + {0, NULL} +}; #endif -void ERR_load_BUF_strings(void) - { +void +ERR_load_BUF_strings(void) +{ #ifndef OPENSSL_NO_ERR - - if (ERR_func_error_string(BUF_str_functs[0].error) == NULL) - { - ERR_load_strings(0,BUF_str_functs); - ERR_load_strings(0,BUF_str_reasons); - } -#endif + if (ERR_func_error_string(BUF_str_functs[0].error) == NULL) { + ERR_load_strings(0, BUF_str_functs); + ERR_load_strings(0, BUF_str_reasons); } +#endif +} diff --git a/lib/libssl/src/crypto/buffer/buffer.c b/lib/libssl/src/crypto/buffer/buffer.c index b52c59f8a31..4bd55c04ae5 100644 --- a/lib/libssl/src/crypto/buffer/buffer.c +++ b/lib/libssl/src/crypto/buffer/buffer.c @@ -5,21 +5,21 @@ * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. - * + * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * + * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -34,10 +34,10 @@ * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from + * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * + * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -49,7 +49,7 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * + * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence @@ -65,139 +65,126 @@ * that the result fits in an int. */ #define LIMIT_BEFORE_EXPANSION 0x5ffffffc -BUF_MEM *BUF_MEM_new(void) - { +BUF_MEM * +BUF_MEM_new(void) +{ BUF_MEM *ret; - ret=malloc(sizeof(BUF_MEM)); - if (ret == NULL) - { - BUFerr(BUF_F_BUF_MEM_NEW,ERR_R_MALLOC_FAILURE); - return(NULL); - } - ret->length=0; - ret->max=0; - ret->data=NULL; - return(ret); + ret = malloc(sizeof(BUF_MEM)); + if (ret == NULL) { + BUFerr(BUF_F_BUF_MEM_NEW, ERR_R_MALLOC_FAILURE); + return (NULL); } + ret->length = 0; + ret->max = 0; + ret->data = NULL; + return (ret); +} -void BUF_MEM_free(BUF_MEM *a) - { - if(a == NULL) - return; +void +BUF_MEM_free(BUF_MEM *a) +{ + if (a == NULL) + return; - if (a->data != NULL) - { - memset(a->data,0,(unsigned int)a->max); + if (a->data != NULL) { + memset(a->data, 0,(unsigned int)a->max); free(a->data); - } - free(a); } + free(a); +} -int BUF_MEM_grow(BUF_MEM *str, size_t len) - { +int +BUF_MEM_grow(BUF_MEM *str, size_t len) +{ char *ret; size_t n; - if (str->length >= len) - { - str->length=len; - return(len); - } - if (str->max >= len) - { - memset(&str->data[str->length],0,len-str->length); - str->length=len; - return(len); - } + if (str->length >= len) { + str->length = len; + return (len); + } + if (str->max >= len) { + memset(&str->data[str->length], 0,len - str->length); + str->length = len; + return (len); + } /* This limit is sufficient to ensure (len+3)/3*4 < 2**31 */ - if (len > LIMIT_BEFORE_EXPANSION) - { - BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE); + if (len > LIMIT_BEFORE_EXPANSION) { + BUFerr(BUF_F_BUF_MEM_GROW, ERR_R_MALLOC_FAILURE); return 0; - } - n=(len+3)/3*4; + } + n = (len + 3) / 3 * 4; if (str->data == NULL) - ret=malloc(n); + ret = malloc(n); else - ret=realloc(str->data,n); - if (ret == NULL) - { - BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE); - len=0; - } - else - { - str->data=ret; - str->max=n; - memset(&str->data[str->length],0,len-str->length); - str->length=len; - } - return(len); + ret = realloc(str->data, n); + if (ret == NULL) { + BUFerr(BUF_F_BUF_MEM_GROW, ERR_R_MALLOC_FAILURE); + len = 0; + } else { + str->data = ret; + str->max = n; + memset(&str->data[str->length], 0,len - str->length); + str->length = len; } + return (len); +} -int BUF_MEM_grow_clean(BUF_MEM *str, size_t len) - { +int +BUF_MEM_grow_clean(BUF_MEM *str, size_t len) +{ char *ret; size_t n; - if (str->length >= len) - { - memset(&str->data[len],0,str->length-len); - str->length=len; - return(len); - } - if (str->max >= len) - { - memset(&str->data[str->length],0,len-str->length); - str->length=len; - return(len); - } + if (str->length >= len) { + memset(&str->data[len], 0,str->length - len); + str->length = len; + return (len); + } + if (str->max >= len) { + memset(&str->data[str->length], 0,len - str->length); + str->length = len; + return (len); + } /* This limit is sufficient to ensure (len+3)/3*4 < 2**31 */ - if (len > LIMIT_BEFORE_EXPANSION) - { - BUFerr(BUF_F_BUF_MEM_GROW_CLEAN,ERR_R_MALLOC_FAILURE); + if (len > LIMIT_BEFORE_EXPANSION) { + BUFerr(BUF_F_BUF_MEM_GROW_CLEAN, ERR_R_MALLOC_FAILURE); return 0; - } - n=(len+3)/3*4; + } + n = (len + 3) / 3 * 4; if (str->data == NULL) - ret=malloc(n); - else - ret=OPENSSL_realloc_clean(str->data,str->max,n); - if (ret == NULL) - { - BUFerr(BUF_F_BUF_MEM_GROW_CLEAN,ERR_R_MALLOC_FAILURE); - len=0; - } + ret = malloc(n); else - { - str->data=ret; - str->max=n; - memset(&str->data[str->length],0,len-str->length); - str->length=len; - } - return(len); + ret = OPENSSL_realloc_clean(str->data, str->max, n); + if (ret == NULL) { + BUFerr(BUF_F_BUF_MEM_GROW_CLEAN, ERR_R_MALLOC_FAILURE); + len = 0; + } else { + str->data = ret; + str->max = n; + memset(&str->data[str->length], 0, len - str->length); + str->length = len; } + return (len); +} -void BUF_reverse(unsigned char *out, const unsigned char *in, size_t size) - { +void +BUF_reverse(unsigned char *out, const unsigned char *in, size_t size) +{ size_t i; - if (in) - { + if (in) { out += size - 1; for (i = 0; i < size; i++) *out-- = *in++; - } - else - { + } else { unsigned char *q; char c; q = out + size - 1; - for (i = 0; i < size/2; i++) - { + for (i = 0; i < size / 2; i++) { c = *q; *q-- = *out; *out++ = c; - } } } +} diff --git a/lib/libssl/src/crypto/buffer/buffer.h b/lib/libssl/src/crypto/buffer/buffer.h index f8da32b4850..ab1fab44100 100644 --- a/lib/libssl/src/crypto/buffer/buffer.h +++ b/lib/libssl/src/crypto/buffer/buffer.h @@ -5,21 +5,21 @@ * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. - * + * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * + * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -34,10 +34,10 @@ * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from + * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * + * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -49,7 +49,7 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * + * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence @@ -74,12 +74,11 @@ extern "C" { /* Already declared in ossl_typ.h */ /* typedef struct buf_mem_st BUF_MEM; */ -struct buf_mem_st - { +struct buf_mem_st { size_t length; /* current number of bytes */ char *data; size_t max; /* size of buffer */ - }; +}; BUF_MEM *BUF_MEM_new(void); void BUF_MEM_free(BUF_MEM *a); @@ -91,8 +90,8 @@ void * BUF_memdup(const void *data, size_t siz); void BUF_reverse(unsigned char *out, const unsigned char *in, size_t siz); /* safe string functions */ -size_t BUF_strlcpy(char *dst,const char *src,size_t siz); -size_t BUF_strlcat(char *dst,const char *src,size_t siz); +size_t BUF_strlcpy(char *dst, const char *src, size_t siz); +size_t BUF_strlcat(char *dst, const char *src, size_t siz); /* BEGIN ERROR CODES */ -- 2.20.1