Commit graph

56 commits

Author SHA1 Message Date
Rich Salz
b1322259d9 Copyright consolidation 09/10
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-05-17 14:53:16 -04:00
Andy Polyakov
463a7b8cb0 Clean-up *_DEBUG options.
Since NDEBUG is defined unconditionally on command line for release
builds, we can omit *_DEBUG options in favour of effective "all-on"
in debug builds exercised though CI.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Emilia Käsper <emilia@openssl.org>
2016-04-07 21:18:00 +02:00
Matt Caswell
9cb177301f Fix memory issues in BIO_*printf functions
The internal |fmtstr| function used in processing a "%s" format string
in the BIO_*printf functions could overflow while calculating the length
of a string and cause an OOB read when printing very long strings.

Additionally the internal |doapr_outch| function can attempt to write to
an OOB memory location (at an offset from the NULL pointer) in the event of
a memory allocation failure. In 1.0.2 and below this could be caused where
the size of a buffer to be allocated is greater than INT_MAX. E.g. this
could be in processing a very long "%s" format string. Memory leaks can also
occur.

These issues will only occur on certain platforms where sizeof(size_t) >
sizeof(int). E.g. many 64 bit systems. The first issue may mask the second
issue dependent on compiler behaviour.

These problems could enable attacks where large amounts of untrusted data
is passed to the BIO_*printf functions. If applications use these functions
in this way then they could be vulnerable. OpenSSL itself uses these
functions when printing out human-readable dumps of ASN.1 data. Therefore
applications that print this data could be vulnerable if the data is from
untrusted sources. OpenSSL command line applications could also be
vulnerable where they print out ASN.1 data, or if untrusted data is passed
as command line arguments.

Libssl is not considered directly vulnerable. Additionally certificates etc
received via remote connections via libssl are also unlikely to be able to
trigger these issues because of message size limits enforced within libssl.

CVE-2016-0799

Issue reported by Guido Vranken.

Reviewed-by: Andy Polyakov <appro@openssl.org>
2016-02-25 22:45:58 +00:00
Rich Salz
349807608f Remove /* foo.c */ comments
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>
2016-01-26 16:40:43 -05:00
Rich Salz
4fae386cb0 Cleanup CRYPTO_{push,pop}_info
Rename to OPENSSL_mem_debug_{push,pop}.
Remove simple calls; keep only calls used in recursive functions.
Ensure we always push, to simplify so that we can always pop

Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-12-22 09:11:07 -05:00
Matt Caswell
90945fa31a Continue standardising malloc style for libcrypto
Continuing from previous commit ensure our style is consistent for malloc
return checks.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
2015-11-09 22:48:41 +00:00
Andy Polyakov
5f0580ccf1 Harmonize pointer printing and size_t-fy casts.
Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-10-05 09:26:19 +02:00
Richard Levitte
b39fc56061 Identify and move common internal libcrypto header files
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-14 17:21:40 +02:00
Matt Caswell
9d9e37744c Clarify logic in BIO_*printf functions
The static function dynamically allocates an output buffer if the output
grows larger than the static buffer that is normally used. The original
logic implied that |currlen| could be greater than |maxlen| which is
incorrect (and if so would cause a buffer overrun). Also the original
logic would call OPENSSL_malloc to create a dynamic buffer equal to the
size of the static buffer, and then immediately call OPENSSL_realloc to
make it bigger, rather than just creating a buffer than was big enough in
the first place. Thanks to Kevin Wojtysiak (Int3 Solutions) and Paramjot
Oberoi (Int3 Solutions) for reporting this issue.

Reviewed-by: Andy Polyakov <appro@openssl.org>
2015-04-30 23:12:39 +01:00
Viktor Dukhovni
61986d32f3 Code style: space after 'if'
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-16 13:44:59 -04:00
Matt Caswell
b7573c597c Remove dead code from crypto
Some miscellaneous removal of dead code from lib crypto.

Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-03-17 14:48:44 +00:00
Matt Caswell
918bb86529 Unchecked malloc fixes
Miscellaneous unchecked malloc fixes. Also fixed some mem leaks on error
paths as I spotted them along the way.

Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-03-05 09:09:57 +00:00
Matt Caswell
0f113f3ee4 Run util/openssl-format-source -v -c .
Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-01-22 09:20:09 +00:00
Tim Hudson
1d97c84351 mark all block comments that need format preserving so that
indent will not alter them when reformatting comments

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
2014-12-30 22:10:26 +00:00
Andy Polyakov
77519b51db Make bn2dec work on "SIXTY_FOUR_BIT" platforms.
PR: 1456
2007-09-15 17:05:11 +00:00
Geoff Thorpe
209b12814f Fix compilation when HAVE_LONG_LONG isn't defined. 2005-07-26 04:43:31 +00:00
Nils Larsch
2c288b2a7e fix compiler warning; pow10 is also in math.h 2005-05-05 20:57:37 +00:00
Nils Larsch
70f34a5841 some const fixes and cleanup 2005-04-05 10:29:43 +00:00
Geoff Thorpe
032c3ecb18 Protect against gcc's "warning: cast does not match function type". 2004-03-25 02:19:42 +00:00
Richard Levitte
ec5d8a54e9 Remove a warning for conversion double->long. This has impacts on Windows.
PR: 849
2004-03-21 22:39:52 +00:00
Richard Levitte
a2b0de98af To figure out if we're going outside the buffer, use the size of the buffer,
not the size of the integer used to index in said buffer.

PR: 794
Notified by: Rhett Garber <rhett_garber@hp.com>
2003-12-11 18:01:03 +00:00
Geoff Thorpe
d8ec0dcf45 Avoid some shadowed variable names.
Submitted by: Nils Larsch
2003-11-04 00:51:32 +00:00
Geoff Thorpe
8a66d17899 Remove an unnecessary cast that causes certain compilers (eg. mine) some
confusion. Also silence a couple of signed/unsigned warnings.
2003-10-29 05:00:57 +00:00
Richard Levitte
83743ad039 Fix sign bugs.
PR: 621
2003-05-21 14:29:13 +00:00
Richard Levitte
c433d72593 Make %p and %# work properly, at least with pointers and floats. 2003-04-03 23:35:14 +00:00
Ben Laurie
54a656ef08 Security fixes brought forward from 0.9.7. 2002-11-13 15:43:43 +00:00
Richard Levitte
ba8fb52183 Certain flag macros were tested with #if instead if #ifdef... 2002-08-02 11:13:37 +00:00
Bodo Möller
60e5f36d27 make b_print.c consistent with the rest of OpenSSL:
disable assert() except for debug builds
2002-05-14 19:40:58 +00:00
Richard Levitte
06bed64317 Make the huge buffer smaller, so the size becomes reasonable for small-stack environments.
Notified by Verdon Walker <VWalker@novell.com>
2002-05-09 20:14:00 +00:00
Richard Levitte
b4000e8ad8 Move an assert() to avoid core dumps when a static buffer hasn't been given.
Notified by Verdon Walker <VWalker@novell.com>
2002-05-09 18:19:21 +00:00
Ulf Möller
31106cc750 name confusion with HP library function prototype (?) 2001-12-10 18:52:06 +00:00
Dr. Stephen Henson
c2e45f6ddf Win32 fixes:
define LLONG properly for VC++.

stop compiler complaining about signed/unsigned mismatch in apps/engine.c
2001-04-29 16:30:59 +00:00
Richard Levitte
347177e052 Include bn.h so we get BN_LLONG properly defined. Otherwise, we can forget things like %lld 2001-03-27 18:34:04 +00:00
Ulf Möller
bf401a2aef %f conversion bug fix
Submitted by: Henrik Eriksson <henrik.eriksson@axis.com>
2001-02-27 23:59:18 +00:00
Richard Levitte
99b1aaf2ec On some operating systems, MAX is defined. Call ours OSSL_MAX instead 2000-10-22 12:44:12 +00:00
Richard Levitte
827dbcb150 Change the printing mahine used by BIO_printf() and friends so it can
handle an externally provided "static" buffer as well a a dynamic
buffer.  The "static" buffer is filled first, but if overflowed, the
dynamic buffer is used instead, being allocated somewhere i the heap.

This combines the benefits of putting the output in a preallocated
buffer (on the stack, for example) and in a buffer that grows
somewhere in the heap.
2000-09-07 05:50:14 +00:00
Bodo Möller
29dc25e88a Increase print buffer (10K instead of just 2K). 2000-09-05 12:43:39 +00:00
Bodo Möller
affadbef0b Consistency 2000-09-04 15:47:17 +00:00
Richard Levitte
e6629837a9 Added BIO_vprintf() and BIO_vsnprintf(). The former because I've
found myself needing it a number of times, the latter for completeness.
2000-08-18 09:36:59 +00:00
Richard Levitte
26a3a48d65 There have been a number of complaints from a number of sources that names
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-01 22:19:21 +00:00
Bodo Möller
e5c84d5152 New function ERR_error_string_n. 2000-04-14 23:36:15 +00:00
Richard Levitte
3916800fef Let's care about the compiler warnings for both cases, shall we? 2000-03-04 20:19:57 +00:00
Ulf Möller
938d90db71 gcc warnings 2000-03-04 00:21:45 +00:00
Richard Levitte
5ee0d9c4a3 Hack b_print.c to implement asprintf() functionality. Not enabled by
default yet, I wanna play with it a bit more.

For those who don't know: asprintf() is an allocating sprintf.  The
first argument to it is a double indirection to char instead of a
single.
2000-03-02 07:50:02 +00:00
Ulf Möller
96723a3a68 Bug fix.
Pointed out by: Gisle Vanem <gvanem@eunet.no>
2000-02-29 14:47:29 +00:00
Richard Levitte
42a9af38e7 Typo corrected. 2000-02-28 11:30:31 +00:00
Richard Levitte
1b7aee1d4e Short is always promoted to int when passed as a function argument.
This is especially true when it's part of a '...'.
2000-02-27 23:17:18 +00:00
Richard Levitte
a1990dd76d Don't include sys/types.h if NO_SYS_TYPES_H is defined. 2000-02-26 03:55:15 +00:00
Richard Levitte
47c177c7b3 Let's avoid compiler warnings over types.
Actually, this should be resolved by using size_t a bit more, but
that'll be for later.
2000-02-26 01:45:17 +00:00
Geoff Thorpe
7dce5a727a Gets around VC++ compiler pickiness. (long != double)
PR:
2000-02-25 14:50:37 +00:00