Просмотр исходного кода

Merge branch 'master' into next

* master:
  Clarify that exit(1) is called
  Print errors to stderr
  Prevent crashing on startup if openssl can not be loaded

Conflicts:
	doc/UPDATES
Bryan Drewery 13 лет назад
Родитель
Сommit
5579b2f9d8
6 измененных файлов с 15 добавлено и 7 удалено
  1. 3 0
      doc/UPDATES
  2. 1 1
      src/libcrypto.c
  3. 1 1
      src/libssl.c
  4. 4 2
      src/openssl.c
  5. 4 2
      src/shell.c
  6. 2 1
      src/shell.h

+ 3 - 0
doc/UPDATES

@@ -3,6 +3,9 @@ next
   * Properly honor exemptions when kicking matched RBL clients
   * Fix LASTON not being shared
 
+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 */

+ 4 - 2
src/shell.c

@@ -654,6 +654,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");
   }
@@ -683,10 +685,10 @@ void werr(int errnum)
   printf(STR("*** Error code %d\n\n"), errnum);
   printf(STR("Segmentation fault\n"));
 #else
-  printf(STR("Error %d: %s\n"), errnum, werr_tostr(errnum));
+  fprintf(stderr, STR("Error %d: %s\n"), errnum, werr_tostr(errnum));
 #endif
   fatal("", 0);
-  exit(0);				//gcc is stupid :)
+  exit(1); // This is never reached, done for gcc() warnings
 }
 
 char *homedir(bool useconf)

+ 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