[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Always check for usage underflow when removing a file in storage.c
commit 9e36b0beb9dc6fe02d43b4c217841c8164f41774
Author: teor <teor2345@xxxxxxxxx>
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);
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits