Always check for usage underflow when removing a file in storage.c

Part of #22424.
This commit is contained in:
teor 2017-05-28 22:12:09 +10:00
parent f6841ae263
commit 9e36b0beb9
No known key found for this signature in database
GPG Key ID: 740D9E39025272A2

View File

@ -425,7 +425,9 @@ storage_dir_remove_file(storage_dir_t *d,
} }
} }
if (unlink(ipath) == 0) { if (unlink(ipath) == 0) {
if (! BUG(d->usage < size)) {
d->usage -= size; d->usage -= size;
}
} else { } else {
log_warn(LD_FS, "Unable to unlink %s", escaped(path)); log_warn(LD_FS, "Unable to unlink %s", escaped(path));
tor_free(path); tor_free(path);