From: teor Date: Sun, 28 May 2017 12:12:09 +0000 (+1000) Subject: Always check for usage underflow when removing a file in storage.c X-Git-Tag: tor-0.3.1.3-alpha~23^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9e36b0beb9dc6fe02d43b4c217841c8164f41774;p=thirdparty%2Ftor.git Always check for usage underflow when removing a file in storage.c Part of #22424. --- diff --git a/src/common/storagedir.c b/src/common/storagedir.c index 6457f3d009..9140ed29bd 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);