[tor/master] Always check for usage underflow when removing a file in storage.c

30 May
2017
30 May
'17
12:51 p.m.
commit 9e36b0beb9dc6fe02d43b4c217841c8164f41774 Author: teor <teor2345@gmail.com> Date: Sun May 28 22:12:09 2017 +1000 Always check for usage underflow when removing a file in storage.c Part of #22424. --- src/common/storagedir.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/common/storagedir.c b/src/common/storagedir.c index 6457f3d..9140ed2 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);
2926
Age (days ago)
2926
Last active (days ago)
0 comments
1 participants
participants (1)
-
nickm@torproject.org