ソースを参照

* Fix crash after doing conf_add (fixes #434)

Bryan Drewery 17 年 前
コミット
709f4bd85b
1 ファイル変更9 行追加1 行削除
  1. 9 1
      src/binary.c

+ 9 - 1
src/binary.c

@@ -172,7 +172,10 @@ bin_checksum(const char *fname, int todo)
 
     /* encrypt the entire struct with the hash (including hash) */
     edpack(&settings, hash, PACK_ENC);
-    OPENSSL_cleanse(hash, sizeof(hash));
+
+    //Don't clear hash if requested during the write.
+    if (!(todo & GET_CHECKSUM))
+      OPENSSL_cleanse(hash, sizeof(hash));
 
     /* Copy everything up to this point into the new binary (including the settings header/prefix) */
     outmap = (unsigned char*) mmap(0, size, PROT_WRITE, MAP_SHARED, newbin->fd, 0);
@@ -550,6 +553,11 @@ void write_settings(const char *fname, int die, bool doconf)
 
   /* only bother writing anything if we have pack or doconf, checksum is worthless to write out */
   if (bits & (WRITE_PACK|WRITE_CONF)) {
+
+    // Also get the checksum
+    if (die == -1)
+      bits |= GET_CHECKSUM;
+
     if ((hash = bin_checksum(fname, bits))) {
       printf(STR("* Wrote %ssettings to: %s.\n"), ((bits & WRITE_PACK) && !(bits & WRITE_CONF)) ? "pack " :
                                              ((bits & WRITE_CONF) && !(bits & WRITE_PACK)) ? "conf " :