diff options
author | teor <teor2345@gmail.com> | 2017-05-28 22:12:09 +1000 |
---|---|---|
committer | teor <teor2345@gmail.com> | 2017-05-28 22:12:09 +1000 |
commit | 9e36b0beb9dc6fe02d43b4c217841c8164f41774 (patch) | |
tree | 6d3f46b0c3cbbcf4610e32a22772436d6724c58b /src/common/storagedir.c | |
parent | f6841ae26374d3b4d0b479049d7a7c237afffe5c (diff) | |
download | tor-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.c | 4 |
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); |