]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix crash when read_file_to_string() fails in SAVECONF
authorNick Mathewson <nickm@torproject.org>
Thu, 12 May 2011 02:05:41 +0000 (22:05 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 12 May 2011 02:05:41 +0000 (22:05 -0400)
The new behavior is to try to rename the old file if there is one there
that we can't read.  In all likelihood, that will fail too, but at least
we tried, and at least it won't crash.

changes/bug3135 [new file with mode: 0644]
src/or/config.c

diff --git a/changes/bug3135 b/changes/bug3135
new file mode 100644 (file)
index 0000000..d761123
--- /dev/null
@@ -0,0 +1,6 @@
+  o Minor bugfixes
+    - Do not crash when our configuration file becomes unreadable
+      (usually due to a permissions change) between when we start
+      up and when a controller calls SAVECONF.  Fixes bug 3135;
+      bugfix on 0.0.9pre6.
+
index 9cd8149ce89c510cb4a0a4b961ee136b1441be5b..fbfa771ed3cbdb13c14d1abbfb8309ad31bcb132 100644 (file)
@@ -4625,7 +4625,7 @@ write_configuration_file(const char *fname, or_options_t *options)
   switch (file_status(fname)) {
     case FN_FILE:
       old_val = read_file_to_str(fname, 0, NULL);
-      if (strcmpstart(old_val, GENERATED_FILE_PREFIX)) {
+      if (!old_val || strcmpstart(old_val, GENERATED_FILE_PREFIX)) {
         rename_old = 1;
       }
       tor_free(old_val);