summaryrefslogtreecommitdiffstats
path: root/crypto/stack/stack.c
AgeCommit message (Collapse)Author
2016-09-21Don't leak on an OPENSSL_realloc() failureMatt Caswell
If OPENSSL_sk_insert() calls OPENSSL_realloc() and it fails, it was leaking the originally allocated memory. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-19Convert num_alloc to a size_t in stack.c and tweak styleMatt Caswell
We were casting num_alloc to size_t in lots of places, or just using it in a context where size_t makes more sense - so convert it. This simplifies the code a bit. Also tweak the style in stack.c a bit following on from the previous commit Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-19Prevent overflows in stack APIGuido Vranken
Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2016-08-10Add some const castsRich Salz
Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1397)
2016-06-30Constify a bit more OPENSSL_sk_ APIFdaSilvaYY
Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1244)
2016-06-30Use directly zalloc in OPENSSL_sk_dup and OPENSSL_sk_deep_copyFdaSilvaYY
Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1244)
2016-05-21Constify stack and lhash macros.Dr. Stephen Henson
RT#4471 Reviewed-by: Tim Hudson <tjh@openssl.org>
2016-05-20Rename lh_xxx,sk_xxx tp OPENSSL_{LH,SK}_xxxRich Salz
Rename sk_xxx to OPENSSL_sk_xxx and _STACK to OPENSSL_STACK Rename lh_xxx API to OPENSSL_LH_xxx and LHASH_NODE to OPENSSL_LH_NODE Make lhash stuff opaque. Use typedefs for function pointers; makes the code simpler. Remove CHECKED_xxx macros. Add documentation; remove old X509-oriented doc. Add API-compat names for entire old API Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
2016-05-17Copyright consolidation 06/10Rich Salz
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-02-06if no comparison function set make sk_sort no opDr. Stephen Henson
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-01-26Remove /* foo.c */ commentsRich Salz
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>
2015-09-04More zalloc nitsRich Salz
Found on GitHub by dimman Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-09-03remove 0 assignments.Rich Salz
After openssl_zalloc, cleanup more "set to 0/NULL" assignments. Many are from github feedback. Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-08-10RT3999: Remove sub-component version stringsRich Salz
Especially since after the #ifdef cleanups this is not useful. Reviewed-by: Matt Caswell <matt@openssl.org>
2015-05-14Identify and move common internal libcrypto header filesRichard Levitte
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>
2015-05-05memset, memcpy, sizeof consistency fixesRich Salz
Just as with the OPENSSL_malloc calls, consistently use sizeof(*ptr) for memset and memcpy. Remove needless casts for those functions. For memset, replace alternative forms of zero with 0. Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-05-04Use safer sizeof variant in mallocRich Salz
For a local variable: TYPE *p; Allocations like this are "risky": p = OPENSSL_malloc(sizeof(TYPE)); if the type of p changes, and the malloc call isn't updated, you could get memory corruption. Instead do this: p = OPENSSL_malloc(sizeof(*p)); Also fixed a few memset() calls that I noticed while doing this. Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-05-01free NULL cleanup -- codaRich Salz
After the finale, the "real" final part. :) Do a recursive grep with "-B1 -w [a-zA-Z0-9_]*_free" to see if any of the preceeding lines are an "if NULL" check that can be removed. Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-05-01free null cleanup finaleRich Salz
Don't check for NULL before calling OPENSSL_free Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-04-28remove malloc castsRich Salz
Following ANSI C rules, remove the casts from calls to OPENSSL_malloc and OPENSSL_realloc. Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-03-17Fix memset call in stack.cMatt Caswell
The function sk_zero is supposed to zero the elements held within a stack. It uses memset to do this. However it calculates the size of each element as being sizeof(char **) instead of sizeof(char *). This probably doesn't make much practical difference in most cases, but isn't a portable assumption. Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-03-05Make STACK_OF opaque.Dr. Stephen Henson
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-01-24undef cleanup: use memmoveRich Salz
Reviewed-by: Andy Polyakov <appro@openssl.org>
2015-01-22Run util/openssl-format-source -v -c .Matt Caswell
Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-01-06Further comment amendments to preserve formatting prior to source reformatMatt Caswell
Reviewed-by: Tim Hudson <tjh@openssl.org>
2014-06-22Implement sk_deep_copy.Viktor Dukhovni
2008-10-14Type-safe OBJ_bsearch_ex.Ben Laurie
2008-06-04More type-checking.Ben Laurie
2007-01-21Constify version strings and some structures.Dr. Stephen Henson
2004-10-04Oops!Dr. Stephen Henson
2004-10-04Fix race condition when CRL checking is enabled.Dr. Stephen Henson
2004-04-21Extend the index parameter checking from sk_value to sk_set(). Also tidy upGeoff Thorpe
some similar code elsewhere. Thanks to Francesco Petruzzi for bringing this to my attention.
2004-04-02Avoid undefined results when the parameter is out of range.Geoff Thorpe
2003-04-29Include objects.h to get a correct declaration of OBJ_bsearch_ex(),Richard Levitte
not to mention the OBJ_BSEARCH_* macros.
2003-04-29Add an extended variant of sk_find() which returns a non-NULL pointerRichard Levitte
even if an exact match wasn't found.
2001-05-31Fix a memory leak in 'sk_dup' in the case a realloc() fails. Also, tidy upGeoff Thorpe
a bit of weird code in sk_new.
2001-01-28Make sk_sort tolearate a NULL argument.Dr. Stephen Henson
2000-09-17Some platforms define NULL as ((void *)0). Unfortunately, a void*Richard Levitte
can't be used as a function pointer according the the standards. Use a 0 instead and there will be no trouble.
2000-06-16Safe stack reorganisation in terms of function casts.Dr. Stephen Henson
After some messing around this seems to work but needs a few more tests. Working out the syntax for sk_set_cmp_func() (cast it to a function that itself returns a function pointer) was painful :-( Needs some testing to see what other compilers think of this syntax. Also needs similar stuff for ASN1_SET_OF etc etc.
2000-06-08Harmonize indentation.Bodo Möller
2000-06-01There have been a number of complaints from a number of sources that namesRichard Levitte
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.
2000-06-01This is the first of two commits (didn't want to dump them all into theGeoff Thorpe
same one). However, the first will temporarily break things until the second comes through. :-) The safestack.h handling was mapping compare callbacks that externally are of the type (int (*)(type **,type **)) into the underlying callback type used by stack.[ch], which is (int (*)(void *,void *)). After some degree of digging, it appears that the callback type in the underlying stack code should use double pointers too - when the compare operations are invoked (from sk_find and sk_sort), they are being used by bsearch and qsort to compare two pointers to pointers. This change corrects the prototyping (by only casting to the (void*,void*) form at the moment it is needed by bsearch and qsort) and makes the mapping in safestack.h more transparent. It also changes from "void*" to "char*" to stay in keeping with stack.[ch]'s assumed base type of "char". Also - the "const" situation was that safestack.h was throwing away "const"s, and to compound the problem - a close examination of stack.c showed that (const char **) is not really achieving what it is supposed to when the callback is being invoked, what is needed is (const char * const *). So the underlying stack.[ch] and the mapping macros in safestack.h have all been altered to correct this. What will follow are the vast quantities of "const" corrections required in stack-dependant code that was being let "slip" through when safestack.h was discarding "const"s. These now all come up as compiler warnings.
2000-05-31sk_value was also suffering from de-const-ification.Geoff Thorpe
Also, add in a couple of missing declarations in pkcs7 code.
2000-05-31All the little functions created by the IMPLEMENT_STACK_OF() macro willGeoff Thorpe
cast their type-specific STACK into a real STACK and call the underlying sk_*** function. The problem is that if the STACK_OF(..) parameter being passed in has a "const *" qualifier, it is discarded by the cast. I'm currently implementing a fix for this but in the mean-time, this is one case I noticed (a few type-specific sk_**_num() functions pass in const type-specific stacks). If there are other errors in the code where consts are being discarded, we will similarly not notice them. yuck.
2000-05-15Get rid of more non-ANSI declarations.Ulf Möller
2000-02-03ispell (and minor modifications)Ulf Möller
2000-01-30Seek out and destroy another evil cast.Ulf Möller
1999-05-30Another safe stack.Ben Laurie
1999-05-19New functions sk_set, sk_value and sk_num to replace existing macros: this isDr. Stephen Henson
to minimise the effects on existing code.
1999-04-27Add PKCS#12 documentation and new option in x509 to add certificate extensions.Dr. Stephen Henson