From 13847b8db6b676c4f2951a4195758f395b7551a8 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 11 May 2011 22:05:41 -0400 Subject: Fix crash when read_file_to_string() fails in SAVECONF 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. --- src/or/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/or') diff --git a/src/or/config.c b/src/or/config.c index 9cd8149ce8..fbfa771ed3 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -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); -- cgit v1.2.3-54-g00ecf