aboutsummaryrefslogtreecommitdiff
path: root/src/or/statefile.c
diff options
context:
space:
mode:
authorAndrea Shepard <andrea@torproject.org>2014-03-18 17:52:31 -0700
committerNick Mathewson <nickm@torproject.org>2014-03-31 11:27:08 -0400
commitabdf1878a3f8fe366d8bb7f649127880bdbdf82d (patch)
tree047bb6044119bb27a6c19f2452409063ca9173e7 /src/or/statefile.c
parentdf076eccfaa680ee08b8ae866690d9a2a8ba5555 (diff)
downloadtor-abdf1878a3f8fe366d8bb7f649127880bdbdf82d.tar.gz
tor-abdf1878a3f8fe366d8bb7f649127880bdbdf82d.zip
Always check returns from unlink()
Diffstat (limited to 'src/or/statefile.c')
-rw-r--r--src/or/statefile.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/or/statefile.c b/src/or/statefile.c
index 8ab04763d0..2251f25e94 100644
--- a/src/or/statefile.c
+++ b/src/or/statefile.c
@@ -260,7 +260,7 @@ or_state_set(or_state_t *new_state)
static void
or_state_save_broken(char *fname)
{
- int i;
+ int i, res;
file_status_t status;
char *fname2 = NULL;
for (i = 0; i < 100; ++i) {
@@ -274,7 +274,13 @@ or_state_save_broken(char *fname)
log_warn(LD_BUG, "Unable to parse state in \"%s\"; too many saved bad "
"state files to move aside. Discarding the old state file.",
fname);
- unlink(fname);
+ res = unlink(fname);
+ if (res != 0) {
+ log_warn(LD_FS,
+ "Also couldn't discard old state file \"%s\" because "
+ "unlink() failed: %s",
+ fname, strerror(errno));
+ }
} else {
log_warn(LD_BUG, "Unable to parse state in \"%s\". Moving it aside "
"to \"%s\". This could be a bug in Tor; please tell "