Skip to content

Commit

Permalink
Fix compilation on RHEL4.
Browse files Browse the repository at this point in the history
These (very old) systems ship with openssl-0.9.7a which
defines EVP_MAX_MD_SIZE to 36, a smaller constant than bareos'
CRYPTO_DIGEST_MAX_SIZE (64). This mismatch results in the following
error on attempt to compile crypto_openssl.c:

	crypto_openssl.c:58:2: #error "EVP_MAX_MD_SIZE != CRYPTO_DIGEST_MAX_SIZE, please update src/lib/crypto.h"

The purpose of the preprocessor sanity check that causes this error is
to make sure that various arrays of length CRYPTO_DIGEST_MAX_SIZE are
large enough for all message digests. So all we actually need to check
for is that EVP_MAX_MD_SIZE is no larger than CRYPTO_DIGEST_MAX_SIZE.

Weakening the condition of the above check from "!=" to ">" turned
out to be enough to compile bareos on Red Hat Enterprise Linux 4
(using --client-only though). The resulting executable worked with
no problems.

This patch also adds a comment that explains the purpose of the check.

Signed-off-by: Marco van Wieringen <marco.van.wieringen@bareos.com>
  • Loading branch information
Andre Noll authored and Marco van Wieringen committed Nov 13, 2013
1 parent cbb2584 commit 5b1ebf8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/lib/crypto_openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@

/*
* Sanity checks.
*
* Various places in the bareos source code define arrays of size
* CRYPTO_DIGEST_MAX_SIZE. Make sure this is large enough for all EVP digest
* routines supported by openssl.
*/
#if (EVP_MAX_MD_SIZE != CRYPTO_DIGEST_MAX_SIZE)
#error "EVP_MAX_MD_SIZE != CRYPTO_DIGEST_MAX_SIZE, please update src/lib/crypto.h"
#if (EVP_MAX_MD_SIZE > CRYPTO_DIGEST_MAX_SIZE)
#error "EVP_MAX_MD_SIZE > CRYPTO_DIGEST_MAX_SIZE, please update src/lib/crypto.h"
#endif

#if (EVP_MAX_BLOCK_LENGTH != CRYPTO_CIPHER_MAX_BLOCK_SIZE)
Expand Down

0 comments on commit 5b1ebf8

Please sign in to comment.