aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@gmail.com>2011-11-25 17:39:45 +0100
committerGeorge Kadianakis <desnacked@gmail.com>2011-11-25 17:39:45 +0100
commit1df6b5a734acd381d49a57bb689c7dcd2cd66ad9 (patch)
tree59f3a273c42b65cc5c8eb00dbfc6ccc94643a684
parent4938bcc06a41b95f47def181ce03a7ade805595b (diff)
downloadtor-1df6b5a734acd381d49a57bb689c7dcd2cd66ad9.tar.gz
tor-1df6b5a734acd381d49a57bb689c7dcd2cd66ad9.zip
Move broken primes to dynamic_dh_modulus.broken.
-rw-r--r--src/common/crypto.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 1974a3931b..da3b80becb 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -1900,6 +1900,7 @@ crypto_get_stored_dynamic_dh_modulus(const char *fname)
char *contents = NULL;
DH *dh = NULL;
int dh_codes;
+ char *fname_new = NULL;
BIGNUM *dynamic_dh_modulus = BN_new();
tor_assert(fname);
@@ -1951,6 +1952,24 @@ crypto_get_stored_dynamic_dh_modulus(const char *fname)
goto done;
err:
+
+ { /* move broken prime to $filename.broken */
+
+ fname_new = tor_malloc(strlen(fname) + 8);
+
+ /* no can do if these functions return error */
+ strlcpy(fname_new, fname, strlen(fname) + 8);
+ strlcat(fname_new, ".broken", strlen(fname) + 8);
+
+ log_warn(LD_GENERAL, "Moving broken dynamic DH prime to '%s'.", fname_new);
+
+ if (replace_file(fname, fname_new))
+ log_warn(LD_GENERAL, "Error while moving '%s' to '%s'.", fname, fname_new);
+
+ tor_free(fname_new);
+
+ }
+
if (dynamic_dh_modulus) {
BN_free(dynamic_dh_modulus);
dynamic_dh_modulus = NULL;