aboutsummaryrefslogtreecommitdiff
path: root/src/util/crypto_rsa.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-12-09 15:38:55 +0000
committerChristian Grothoff <christian@grothoff.org>2012-12-09 15:38:55 +0000
commit101b56cdd67b56b4db3be7a50d9050d2a1743715 (patch)
tree65fa45ef0f625551c6e94c6271ce3e74a3b36563 /src/util/crypto_rsa.c
parent36a48508667b24317d2c64cc261d6c03141111c4 (diff)
downloadgnunet-101b56cdd67b56b4db3be7a50d9050d2a1743715.tar.gz
gnunet-101b56cdd67b56b4db3be7a50d9050d2a1743715.zip
adding GNUNET_DISK_file_backup function; fixing #2646
Diffstat (limited to 'src/util/crypto_rsa.c')
-rw-r--r--src/util/crypto_rsa.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c
index ff99ecf0b..cd9a33f61 100644
--- a/src/util/crypto_rsa.c
+++ b/src/util/crypto_rsa.c
@@ -641,12 +641,11 @@ try_read_key (const char *filename)
641 if (fs > UINT16_MAX) 641 if (fs > UINT16_MAX)
642 { 642 {
643 LOG (GNUNET_ERROR_TYPE_ERROR, 643 LOG (GNUNET_ERROR_TYPE_ERROR,
644 _("File `%s' does not contain a valid private key (too long, %llu bytes). Deleting it.\n"), 644 _("File `%s' does not contain a valid private key (too long, %llu bytes). Renaming it.\n"),
645 filename, 645 filename,
646 (unsigned long long) fs); 646 (unsigned long long) fs);
647 GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fd)); 647 GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fd));
648 if (0 != UNLINK (filename)) 648 GNUNET_DISK_file_backup (filename);
649 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "unlink", filename);
650 return NULL; 649 return NULL;
651 } 650 }
652 651
@@ -662,8 +661,7 @@ try_read_key (const char *filename)
662 filename, 661 filename,
663 (unsigned long long) fs); 662 (unsigned long long) fs);
664 GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fd)); 663 GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fd));
665 if (0 != UNLINK (filename)) 664 GNUNET_DISK_file_backup (filename);
666 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "unlink", filename);
667 GNUNET_free (enc); 665 GNUNET_free (enc);
668 return NULL; 666 return NULL;
669 } 667 }
@@ -857,10 +855,7 @@ GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename)
857 LOG (GNUNET_ERROR_TYPE_ERROR, 855 LOG (GNUNET_ERROR_TYPE_ERROR,
858 _("File `%s' does not contain a valid private key. Deleting it.\n"), 856 _("File `%s' does not contain a valid private key. Deleting it.\n"),
859 filename); 857 filename);
860 if (0 != UNLINK (filename)) 858 GNUNET_DISK_file_backup (filename);
861 {
862 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "unlink", filename);
863 }
864 } 859 }
865 GNUNET_free (enc); 860 GNUNET_free (enc);
866 if (GNUNET_YES != 861 if (GNUNET_YES !=