commit: f0d6606d87d78abd643d758da79a0f5869bf9321
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Nov 18 07:49:52 2025 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Nov 18 07:49:52 2025 +0000
URL: https://gitweb.gentoo.org/proj/steve.git/commit/?id=f0d6606d
Block returning more tokens than held
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
steve.cxx | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/steve.cxx b/steve.cxx
index 6d632ce..6b47968 100644
--- a/steve.cxx
+++ b/steve.cxx
@@ -207,6 +207,16 @@ static void steve_write(
return;
}
+ if (state->processes[fi->fh].tokens_held < size) {
+ fprintf(stderr, "Warning: process %ld tried to return %zd
tokens while holding only %d tokens, capping\n",
+ fi->fh, size,
state->processes[fi->fh].tokens_held);
+ size = state->processes[fi->fh].tokens_held;
+ }
+ if (size == 0) {
+ fuse_reply_err(req, ENOSPC);
+ return;
+ }
+
state->tokens += size;
state->processes[fi->fh].tokens_held -= size;
if (state->verbose)