Always check returns from unlink()

This commit is contained in:
Andrea Shepard
2014-03-18 17:52:31 -07:00
committed by Nick Mathewson
parent df076eccfa
commit abdf1878a3
6 changed files with 59 additions and 13 deletions
+17 -4
View File
@@ -1254,7 +1254,11 @@ networkstatus_set_current_consensus(const char *consensus,
/* Even if we had enough signatures, we'd never use this as the
* latest consensus. */
if (was_waiting_for_certs && from_cache)
unlink(unverified_fname);
if (unlink(unverified_fname) != 0) {
log_warn(LD_FS,
"Failed to unlink %s: %s",
unverified_fname, strerror(errno));
}
}
goto done;
} else {
@@ -1264,8 +1268,13 @@ networkstatus_set_current_consensus(const char *consensus,
"consensus");
result = -2;
}
if (was_waiting_for_certs && (r < -1) && from_cache)
unlink(unverified_fname);
if (was_waiting_for_certs && (r < -1) && from_cache) {
if (unlink(unverified_fname) != 0) {
log_warn(LD_FS,
"Failed to unlink %s: %s",
unverified_fname, strerror(errno));
}
}
goto done;
}
}
@@ -1313,7 +1322,11 @@ networkstatus_set_current_consensus(const char *consensus,
waiting->body = NULL;
waiting->set_at = 0;
waiting->dl_failed = 0;
unlink(unverified_fname);
if (unlink(unverified_fname) != 0) {
log_warn(LD_FS,
"Failed to unlink %s: %s",
unverified_fname, strerror(errno));
}
}
/* Reset the failure count only if this consensus is actually valid. */