Parcourir la source

Prevent crashing on startup if openssl can not be loaded

Bryan Drewery il y a 13 ans
Parent
commit
8c6ba17a56
6 fichiers modifiés avec 13 ajouts et 5 suppressions
  1. 3 0
      doc/UPDATES
  2. 1 1
      src/libcrypto.c
  3. 1 1
      src/libssl.c
  4. 4 2
      src/openssl.c
  5. 2 0
      src/shell.c
  6. 2 1
      src/shell.h

+ 3 - 0
doc/UPDATES

@@ -1,3 +1,6 @@
+maint
+  * Prevent crashing on startup if openssl can not be loaded
+
 1.4.1 - http://wraith.botpack.net/milestone/1.4.1
   * Update server list, 'set -yes servers -' and 'set -yes servers6 -' to get new list.
   * Remove 'chanset +meankicks'. You can customize your kicks in doc/responses.txt and recompile.

+ 1 - 1
src/libcrypto.c

@@ -107,7 +107,7 @@ int load_libcrypto() {
     }
   }
   if (!libcrypto_handle) {
-    sdprintf("Unable to find libcrypto");
+    fprintf(stderr, STR("Unable to find libcrypto\n"));
     return(1);
   }
 

+ 1 - 1
src/libssl.c

@@ -80,7 +80,7 @@ int load_libssl() {
     }
   }
   if (!libssl_handle) {
-    sdprintf("Unable to find libssl");
+    fprintf(stderr, STR("Unable to find libssl\n"));
     return(1);
   }
 

+ 4 - 2
src/openssl.c

@@ -28,6 +28,7 @@
 #include "common.h"
 #include "main.h"
 #include "dl.h"
+#include "shell.h"
 #include <bdlib/src/String.h>
 #include <bdlib/src/Array.h>
 
@@ -66,8 +67,9 @@ static DH* tmp_dh_callback(SSL* ssl, int is_export, int keylength) {
 }
 
 int init_openssl() {
-  load_libcrypto();
-  load_libssl();
+  if (load_libcrypto() || load_libssl()) {
+    werr(ERR_LIBS);
+  }
 
 #ifdef EGG_SSL_EXT
   /* good place to init ssl stuff */

+ 2 - 0
src/shell.c

@@ -653,6 +653,8 @@ const char *werr_tostr(int errnum)
     return STR("Binary data is not initialized; try ./binary -C");
   case ERR_TOOMANYBOTS:
     return STR("Too many bots defined. 5 max. Too many will lead to klines.\nSpread out into multiple accounts/shells/ip ranges.");
+  case ERR_LIBS:
+    return STR("Failed to load required libraries");
   default:
     return STR("Unforseen error");
   }

+ 2 - 1
src/shell.h

@@ -23,7 +23,8 @@
 #define ERR_NOHOMEDIR	21
 #define ERR_NOTINIT	22
 #define ERR_TOOMANYBOTS 23
-#define ERR_MAX         24
+#define ERR_LIBS	24
+#define ERR_MAX         25
 
 #define DETECT_LOGIN 	1
 #define DETECT_TRACE 	2