From 908eea1202459c8ffdf8e43eb310cf8690693824 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 26 Jun 2022 12:57:06 +0000 Subject: [PATCH] s3:dbwrap_watch: define/use DBWRAP_MAX_WATCHERS dbwrap backends are unlikely to be able to store UINT32_MAX*DBWRAP_WATCHER_BUF_LENGTH in a single record and most likely also not with the whole database! DBWRAP_MAX_WATCHERS = INT32_MAX/DBWRAP_WATCHER_BUF_LENGTH should be enough and makes further changes easier as we don't need to care about size_t overflows. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125 Signed-off-by: Stefan Metzmacher Reviewed-by: Jeremy Allison Reviewed-by: Ralph Boehme --- source3/lib/dbwrap/dbwrap_watch.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source3/lib/dbwrap/dbwrap_watch.c b/source3/lib/dbwrap/dbwrap_watch.c index 9d3e44a2728..029f590825a 100644 --- a/source3/lib/dbwrap/dbwrap_watch.c +++ b/source3/lib/dbwrap/dbwrap_watch.c @@ -41,6 +41,7 @@ struct dbwrap_watcher { }; #define DBWRAP_WATCHER_BUF_LENGTH (SERVER_ID_BUF_LENGTH + sizeof(uint64_t)) +#define DBWRAP_MAX_WATCHERS (INT32_MAX/DBWRAP_WATCHER_BUF_LENGTH) /* * Watched records contain a header of: @@ -328,7 +329,7 @@ static void dbwrap_watched_add_watcher( dbufs[1].dsize = num_watchers * DBWRAP_WATCHER_BUF_LENGTH; - if (num_watchers >= UINT32_MAX) { + if (num_watchers >= DBWRAP_MAX_WATCHERS) { DBG_DEBUG("Can't handle %zu watchers\n", num_watchers+1); state->status = NT_STATUS_INSUFFICIENT_RESOURCES;