Browse Source

Add crypto-initializer functions to those whose return values must be checked

Nick Mathewson 8 years ago
parent
commit
10fdee6285
3 changed files with 8 additions and 4 deletions
  1. 2 1
      src/common/crypto.c
  2. 2 2
      src/common/crypto.h
  3. 4 1
      src/test/test_workqueue.c

+ 2 - 1
src/common/crypto.c

@@ -322,7 +322,8 @@ int
 crypto_global_init(int useAccel, const char *accelName, const char *accelDir)
 {
   if (!crypto_global_initialized_) {
-    crypto_early_init();
+    if (crypto_early_init() < 0)
+      return -1;
 
     crypto_global_initialized_ = 1;
 

+ 2 - 2
src/common/crypto.h

@@ -112,10 +112,10 @@ typedef struct crypto_dh_t crypto_dh_t;
 /* global state */
 const char * crypto_openssl_get_version_str(void);
 const char * crypto_openssl_get_header_version_str(void);
-int crypto_early_init(void);
+int crypto_early_init(void) ATTR_WUR;
 int crypto_global_init(int hardwareAccel,
                        const char *accelName,
-                       const char *accelPath);
+                       const char *accelPath) ATTR_WUR;
 void crypto_thread_cleanup(void);
 int crypto_global_cleanup(void);
 

+ 4 - 1
src/test/test_workqueue.c

@@ -390,7 +390,10 @@ main(int argc, char **argv)
 
   init_logging(1);
   network_init();
-  crypto_global_init(1, NULL, NULL);
+  if (crypto_global_init(1, NULL, NULL) < 0) {
+    printf("Couldn't initialize crypto subsystem; exiting.\n");
+    return 1;
+  }
   if (crypto_seed_rng() < 0) {
     printf("Couldn't seed RNG; exiting.\n");
     return 1;