]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Always check for usage underflow when removing a file in storage.c
authorteor <teor2345@gmail.com>
Sun, 28 May 2017 12:12:09 +0000 (22:12 +1000)
committerteor <teor2345@gmail.com>
Sun, 28 May 2017 12:12:09 +0000 (22:12 +1000)
Part of #22424.

src/common/storagedir.c

index 6457f3d0091ba0f64aa4cd9609e01d09b30d5579..9140ed29bdef517f739e1b166f6a87fc7bf8c8d5 100644 (file)
@@ -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);