Permalink
Browse files

Check OpenSSL library version at runtime

This patch checks OpenSSL library version on stud startup
and warns if stud was started on system with different
library version.

Conflicts:

	stud.c
  • Loading branch information...
1 parent 3906fa8 commit deb2fe1f9bb1164a1927f96d0de879fade92fad9 Jamie Turner committed Dec 12, 2011
Showing with 24 additions and 0 deletions.
  1. +24 −0 stud.c
View
24 stud.c
@@ -91,6 +91,7 @@ static int listener_socket;
static int child_num;
static pid_t *child_pids;
static SSL_CTX *ssl_ctx;
+
#ifdef USE_SHARED_CACHE
static ev_io shcupd_listener;
static int shcupd_socket;
@@ -104,6 +105,8 @@ typedef struct shcupd_peer_opt {
#endif /*USE_SHARED_CACHE*/
+long openssl_version;
+
/* Command line Options */
typedef enum {
ENC_TLS,
@@ -1697,11 +1700,32 @@ void init_signals() {
fail("sigaction - sigchld");
}
+void openssl_check_version() {
+ /* detect OpenSSL version in runtime */
+ openssl_version = SSLeay();
+
+ /* check if we're running the same openssl that we were */
+ /* compiled with */
+ if ((openssl_version ^ OPENSSL_VERSION_NUMBER) & ~0xff0L) {
+ ERR(
+ "WARNING: {core} OpenSSL version mismatch; stud was compiled with %lx, now using %lx.\n",
+ (unsigned long int) OPENSSL_VERSION_NUMBER,
+ (unsigned long int) openssl_version
+ );
+ /* now what? exit now? */
+ /* exit(1); */
+ }
+
+ LOG("{core} Using OpenSSL version %lx.\n", (unsigned long int) openssl_version);
+}
+
/* Process command line args, create the bound socket,
* spawn child (worker) processes, and respawn if any die */
int main(int argc, char **argv) {
parse_cli(argc, argv);
+ openssl_check_version();
+
init_signals();
init_globals();

0 comments on commit deb2fe1

Please sign in to comment.