From 942e9ca19be81fc8acb3a1ab30e7f58350ba0489 Mon Sep 17 00:00:00 2001 From: yena Date: Wed, 12 Aug 2026 17:13:59 +0900 Subject: [PATCH] out_s3: guard current_buffer_size subtraction against underflow Buffer files recovered from a previous run are not accounted into current_buffer_size at startup, but s3_store_file_delete() subtracted their size unconditionally. The unsigned counter wraps to ~2^64 and the store_dir_limit_size check then rejects every new chunk (Buffer is full / chunk cannot be retried), causing data loss until restart. Clamp the subtraction at zero, matching the guard already used on the quarantine accounting path. Fixes #12270 Signed-off-by: yena --- plugins/out_s3/s3_store.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/plugins/out_s3/s3_store.c b/plugins/out_s3/s3_store.c index fbaf1753c1d..5a263e52c66 100644 --- a/plugins/out_s3/s3_store.c +++ b/plugins/out_s3/s3_store.c @@ -476,7 +476,19 @@ int s3_store_file_delete(struct flb_s3 *ctx, struct s3_file *s3_file) struct flb_fstore_file *fsf; fsf = s3_file->fsf; - ctx->current_buffer_size -= s3_file->size; + + /* + * Files recovered from a previous run are not accounted into + * current_buffer_size at startup, so guard the subtraction to keep + * the unsigned counter from underflowing; a wrapped counter makes + * the store_dir_limit_size check reject every new chunk. + */ + if (ctx->current_buffer_size >= s3_file->size) { + ctx->current_buffer_size -= s3_file->size; + } + else { + ctx->current_buffer_size = 0; + } /* permanent deletion */ flb_fstore_file_delete(ctx->fs, fsf);