aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/mem.c
Commit message (Collapse)AuthorAgeFilesLines
* Remove /* foo.c */ commentsRich Salz2016-01-261-1/+0
| | | | | | | | | | | | This was done by the following find . -name '*.[ch]' | /tmp/pl where /tmp/pl is the following three-line script: print unless $. == 1 && m@/\* .*\.[ch] \*/@; close ARGV if eof; # Close file to reset $. And then some hand-editing of other files. Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
* Enable/disable crypto-mdebug just like other featuresViktor Dukhovni2016-01-111-5/+5
| | | | | | Also always abort() on leak failure. Reviewed-by: Stephen Henson <steve@openssl.org>
* mem functions cleanupRich Salz2016-01-071-240/+96
| | | | | | | | | | | | | | | | | Only two macros CRYPTO_MDEBUG and CRYPTO_MDEBUG_ABORT to control this. If CRYPTO_MDEBUG is not set, #ifdef out the whole debug machinery. (Thanks to Jakob Bohm for the suggestion!) Make the "change wrapper functions" be the only paradigm. Wrote documentation! Format the 'set func' functions so their paramlists are legible. Format some multi-line comments. Remove ability to get/set the "memory debug" functions at runtme. Remove MemCheck_* and CRYPTO_malloc_debug_init macros. Add CRYPTO_mem_debug(int flag) function. Add test/memleaktest. Rename CRYPTO_malloc_init to OPENSSL_malloc_init; remove needless calls. Reviewed-by: Richard Levitte <levitte@openssl.org>
* Rename *_realloc_clean to *_clear_reallocRich Salz2015-12-221-1/+1
| | | | | | | Just like *_clear_free routines. Previously undocumented, used a half-dozen times within OpenSSL source. Reviewed-by: Richard Levitte <levitte@openssl.org>
* Also change the non-debug versions to use size_tKurt Roeckx2015-12-221-2/+2
| | | | | Reviewed-by: Richard Levitte <levitte@openssl.org> MR: #1518
* Modify the lower level memory allocation routines to take size_tRichard Levitte2015-12-171-14/+14
| | | | | | We've been using int for the size for a long time, it's about time... Reviewed-by: Rich Salz <rsalz@openssl.org>
* mem-cleanup, cont'd.Rich Salz2015-12-161-22/+0
| | | | | | | Remove LEVITTE_DEBUG_MEM. Remove {OPENSSL,CRYPTO}_remalloc. Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
* Rename some BUF_xxx to OPENSSL_xxxRich Salz2015-12-161-9/+0
| | | | | | | | | Rename BUF_{strdup,strlcat,strlcpy,memdup,strndup,strnlen} to OPENSSL_{strdup,strlcat,strlcpy,memdup,strndup,strnlen} Add #define's for the old names. Add CRYPTO_{memdup,strndup}, called by OPENSSL_{memdup,strndup} macros. Reviewed-by: Tim Hudson <tjh@openssl.org>
* Add and use OPENSSL_zallocRich Salz2015-09-021-4/+11
| | | | | | | | | There are many places (nearly 50) where we malloc and then memset. Add an OPENSSL_zalloc routine to encapsulate that. (Missed one conversion; thanks Richard) Also fixes GH328 Reviewed-by: Richard Levitte <levitte@openssl.org>
* Remove _locked memory functions.Rich Salz2015-08-261-119/+0
| | | | | | Undocumented, unused, unnecessary (replaced by secure arena). Reviewed-by: Richard Levitte <levitte@openssl.org>
* More secure storage of key material.Rich Salz2015-06-231-1/+72
| | | | | | | | | Add secure heap for storage of private keys (when possible). Add BIO_s_secmem(), CBIGNUM, etc. Add BIO_CTX_secure_new so all BIGNUM's in the context are secure. Contributed by Akamai Technologies under the Corporate CLA. Reviewed-by: Richard Levitte <levitte@openssl.org>
* Identify and move common internal libcrypto header filesRichard Levitte2015-05-141-1/+1
| | | | | | | | | | | | | There are header files in crypto/ that are used by a number of crypto/ submodules. Move those to crypto/include/internal and adapt the affected source code and Makefiles. The header files that got moved are: crypto/cryptolib.h crypto/md32_common.h Reviewed-by: Rich Salz <rsalz@openssl.org>
* free null cleanup finaleRich Salz2015-05-011-2/+1
| | | | | | Don't check for NULL before calling OPENSSL_free Reviewed-by: Richard Levitte <levitte@openssl.org>
* free cleanup almost the finaleRich Salz2015-04-301-2/+10
| | | | | | | | | | Add OPENSSL_clear_free which merges cleanse and free. (Names was picked to be similar to BN_clear_free, etc.) Removed OPENSSL_freeFunc macro. Fixed the small simple ones that are left: CRYPTO_free CRYPTO_free_locked OPENSSL_free_locked Reviewed-by: Richard Levitte <levitte@openssl.org>
* remove malloc castsRich Salz2015-04-281-1/+1
| | | | | | | Following ANSI C rules, remove the casts from calls to OPENSSL_malloc and OPENSSL_realloc. Reviewed-by: Richard Levitte <levitte@openssl.org>
* Fix CRYPTO_strdupLoganaden Velvindron2015-04-221-0/+3
| | | | | | | | | | | | | | The function CRYPTO_strdup (aka OPENSSL_strdup) fails to check the return value from CRYPTO_malloc to see if it is NULL before attempting to use it. This patch adds a NULL check. RT3786 Signed-off-by: Matt Caswell <matt@openssl.org> (cherry picked from commit 37b0cf936744d9edb99b5dd82cae78a7eac6ad60) Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit 20d21389c8b6f5b754573ffb6a4dc4f3986f2ca4)
* Run util/openssl-format-source -v -c .Matt Caswell2015-01-221-303/+342
| | | | Reviewed-by: Tim Hudson <tjh@openssl.org>
* Fix datarace reported by valgrind/helgrindRussell Coker2014-11-101-4/+8
| | | | | | | | | | | This doesn't really fix the datarace but changes it so it can only happens once. This isn't really a problem since we always just set it to the same value. We now just stop writing it after the first time. PR3584, https://bugs.debian.org/534534 Signed-off-by: Kurt Roeckx <kurt@roeckx.be> Reviewed-by: Rich Salz <rsalz@openssl.org>
* Version skew reduction: trivia (I hope).Ben Laurie2012-06-031-3/+1
|
* Check for potentially exploitable overflows in asn1_d2i_read_bioDr. Stephen Henson2012-04-191-0/+4
| | | | | | | | BUF_mem_grow and BUF_mem_grow_clean. Refuse attempts to shrink buffer in CRYPTO_realloc_clean. Thanks to Tavis Ormandy, Google Security Team, for discovering this issue and to Adam Langley <agl@chromium.org> for fixing it. (CVE-2012-2110)
* No need to disable leak checking for FIPS builds now we use internalDr. Stephen Henson2011-04-121-1/+1
| | | | memory callbacks.
* Add additional OPENSSL_init() handling add dummy call to (hopefully)Dr. Stephen Henson2011-04-011-0/+3
| | | | ensure OPENSSL_init() is always linked into an application.
* Move locking and thread ID functions into new files lock.c and thr_id.c,Dr. Stephen Henson2011-01-271-1/+1
| | | | redirect locking to minimal FIPS_lock() function where required.
* Revert the size_t modifications from HEAD that had led to moreGeoff Thorpe2008-11-121-15/+15
| | | | | | knock-on work than expected - they've been extracted into a patch series that can be completed elsewhere, or in a different branch, before merging back to HEAD.
* Fix prototypes.Dr. Stephen Henson2008-11-021-2/+2
|
* size_tification.Ben Laurie2008-11-011-13/+13
|
* Add JPAKE.Ben Laurie2008-10-261-0/+7
|
* Profiling revealed that OPENSSL_cleanse consumes *more* CPU time thanAndy Polyakov2007-05-141-2/+8
| | | | | sha1_block_data_order when hashing short messages. Move OPENSSL_cleanse to "cpuid" assembler module and gain 2x.
* CRYPTO_malloc(), CRYPTO_realloc() and variants of them should return NULLRichard Levitte2003-12-011-4/+4
| | | | | | if the give size is 0. This is a thought that came up in PR 751.
* In realloc, don't destroy the old memory area if a new one couldn't beRichard Levitte2003-10-071-3/+7
| | | | | allocated. Notified by Daniel Lucq <daniel@lucq.org>
* Make sure the memory allocation routines check for negative sizesRichard Levitte2003-02-191-0/+10
|
* Cleanse memory using the new OPENSSL_cleanse() function.Richard Levitte2002-11-281-1/+1
| | | | I've covered all the memset()s I felt safe modifying, but may have missed some.
* Add OPENSSL_cleanse() to help cleanse memory and avoid certain compilerRichard Levitte2002-11-271-0/+14
| | | | | and linker optimizations. PR: 343
* Security fixes brought forward from 0.9.7.Ben Laurie2002-11-131-2/+23
|
* If CRYPTO_realloc() is called with a NULL pointer, have it callRichard Levitte2002-08-011-0/+3
| | | | | OPENSSL_malloc(). PR: 187
* No functional change, but slightly improved code clarity.Bodo Möller2001-01-101-3/+6
|
* After discussion with Richard, change the new API for extended memoryBodo Möller2001-01-101-56/+51
| | | | | | allocation callbacks so that it is no longer visible to applications that these live at a different call level than conventional memory allocation callbacks.
* make indentation consistentBodo Möller2001-01-101-14/+14
|
* As response to a user request to be able to use external memoryRichard Levitte2001-01-101-5/+84
| | | | | | handling routines that need file name and line number information, I've added a call level to our memory handling routines to allow that kind of hooking.
* Constification of the data of a hash table. This means the callbackRichard Levitte2000-12-131-10/+10
| | | | | | | functions need to be constified, and therefore meant a number of easy changes a little everywhere. Now, if someone could explain to me why OBJ_dup() cheats...
* There have been a number of complaints from a number of sources that namesRichard Levitte2000-06-011-2/+2
| | | | | | | | | like Malloc, Realloc and especially Free conflict with already existing names on some operating systems or other packages. That is reason enough to change the names of the OpenSSL memory allocation macros to something that has a better chance of being unique, like prepending them with OPENSSL_. This change includes all the name changes needed throughout all C files.
* In Message-ID: <003201bfb332$14a07520$0801a8c0@janm.transactionsite.com>,Richard Levitte2000-05-021-18/+29
| | | | | | | | | | | | "Jan Mikkelsen" <janm@transactionsite.com> correctly states that the OpenSSL header files have #include's and extern "C"'s in an incorrect order. Thusly fixed. Also, make the memory debugging routines defined and declared with prototypes, and use void* instead of char* for memory blobs. And last of all, redo the ugly callback construct for elegance and better definition (with prototypes).
* Make gcc 2.95.2 happy again, even under ``-Wall -Wshadow -Wpointer-arith ↵Ralf S. Engelschall2000-02-111-1/+1
| | | | | | -Wcast-align -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline''.
* Source code cleanups: Use void * rather than char * in lhash,Ulf Möller2000-01-301-4/+4
| | | | eliminate some of the -Wcast-qual warnings (debug-ben-strict target)
* Late break-in patch for MacOS support.Andy Polyakov1999-12-191-1/+1
|
* - Don't assume that int and size_t have the same representationBodo Möller1999-12-181-37/+73
| | | | | | | | (and that malloc can be called with an int argument). - Use proper prototypes (with argument list) for various function pointers, avoid casts (however there are still many such cases left in these files). - Avoid collissions in app_info_cmp if sizeof int != sizeof long. - Use CRYPTO_LOCK_MALLOC in mem_dbg.c.
* - Added more documentation in CHANGES.Richard Levitte1999-12-181-12/+32
| | | | | | | | | | | | - Made CRYPTO_MDEBUG even less used in crypto.h, giving MemCheck_start() and MemCheck_stop() only one possible definition. - Made the values of the debug function pointers in mem.c dependent on the existence of the CRYPTO_MDEBUG macro, and made the rest of the code understand the NULL case. That's it. With this code, the old behvior of the debug functionality is restored, but you can still opt to have it on, even when the library wasn't compiled with a defined CRYPTO_MDEBUG.
* Rebuild of the OpenSSL memory allocation and deallocation routines.Richard Levitte1999-12-171-538/+72
| | | | | | | | | | | | | | | | | | | | | | | With this change, the following is provided and present at all times (meaning CRYPTO_MDEBUG is no longer required to get this functionality): - hooks to provide your own allocation and deallocation routines. They have to have the same interface as malloc(), realloc() and free(). They are registered by calling CRYPTO_set_mem_functions() with the function pointers. - hooks to provide your own memory debugging routines. The have to have the same interface as as the CRYPTO_dbg_*() routines. They are registered by calling CRYPTO_set_mem_debug_functions() with the function pointers. I moved everything that was already built into OpenSSL and did memory debugging to a separate file (mem_dbg.c), to make it clear what is what. With this, the relevance of the CRYPTO_MDEBUG has changed. The only thing in crypto/crypto.h that it affects is the definition of the MemCheck_start and MemCheck_stop macros.
* The info removal code was overcomplicated, and error-prone (references being ↵Richard Levitte1999-11-121-24/+11
| | | | wrongly decreased). Fixed.
* Avoid deadlock.Bodo Möller1999-11-121-1/+15
|