summaryrefslogtreecommitdiff
path: root/src/common/util.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-03-31 11:57:56 -0400
committerNick Mathewson <nickm@torproject.org>2014-03-31 11:57:56 -0400
commitc0441cca8b483882f5676b98081f0fe4b52d3ae1 (patch)
tree0f6234deb72feb4de4c80ecbf4b0f0b0e89269f7 /src/common/util.c
parent4ebad0d947cbb74b674468e6601894468629f814 (diff)
parent3118af2d5fca7999a94d73690d83463ddacf9acb (diff)
downloadtor-c0441cca8b483882f5676b98081f0fe4b52d3ae1.tar.gz
tor-c0441cca8b483882f5676b98081f0fe4b52d3ae1.zip
Merge branch 'bug8787_squashed'
Diffstat (limited to 'src/common/util.c')
-rw-r--r--src/common/util.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/common/util.c b/src/common/util.c
index a0adb15ffe..a50f2566db 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -2141,6 +2141,7 @@ static int
finish_writing_to_file_impl(open_file_t *file_data, int abort_write)
{
int r = 0;
+
tor_assert(file_data && file_data->filename);
if (file_data->stdio_file) {
if (fclose(file_data->stdio_file)) {
@@ -2157,7 +2158,13 @@ finish_writing_to_file_impl(open_file_t *file_data, int abort_write)
if (file_data->rename_on_close) {
tor_assert(file_data->tempname && file_data->filename);
if (abort_write) {
- unlink(file_data->tempname);
+ int res = unlink(file_data->tempname);
+ if (res != 0) {
+ /* We couldn't unlink and we'll leave a mess behind */
+ log_warn(LD_FS, "Failed to unlink %s: %s",
+ file_data->tempname, strerror(errno));
+ r = -1;
+ }
} else {
tor_assert(strcmp(file_data->filename, file_data->tempname));
if (replace_file(file_data->tempname, file_data->filename)) {