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

nickm at torproject.org nickm at torproject.org
Tue May 30 12:51:29 UTC 2017


commit 9e36b0beb9dc6fe02d43b4c217841c8164f41774
Author: teor <teor2345 at 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);





More information about the tor-commits mailing list