aboutsummaryrefslogtreecommitdiff
path: root/src/common/storagedir.c
diff options
context:
space:
mode:
authorteor <teor2345@gmail.com>2017-05-28 22:12:09 +1000
committerteor <teor2345@gmail.com>2017-05-28 22:12:09 +1000
commit9e36b0beb9dc6fe02d43b4c217841c8164f41774 (patch)
tree6d3f46b0c3cbbcf4610e32a22772436d6724c58b /src/common/storagedir.c
parentf6841ae26374d3b4d0b479049d7a7c237afffe5c (diff)
downloadtor-9e36b0beb9dc6fe02d43b4c217841c8164f41774.tar.gz
tor-9e36b0beb9dc6fe02d43b4c217841c8164f41774.zip
Always check for usage underflow when removing a file in storage.c
Part of #22424.
Diffstat (limited to 'src/common/storagedir.c')
-rw-r--r--src/common/storagedir.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/common/storagedir.c b/src/common/storagedir.c
index 6457f3d009..9140ed29bd 100644
--- a/src/common/storagedir.c
+++ b/src/common/storagedir.c
@@ -425,7 +425,9 @@ storage_dir_remove_file(storage_dir_t *d,
}
}
if (unlink(ipath) == 0) {
- d->usage -= size;
+ if (! BUG(d->usage < size)) {
+ d->usage -= size;
+ }
} else {
log_warn(LD_FS, "Unable to unlink %s", escaped(path));
tor_free(path);