]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:dbwrap_watch: define/use DBWRAP_MAX_WATCHERS
authorStefan Metzmacher <metze@samba.org>
Sun, 26 Jun 2022 12:57:06 +0000 (12:57 +0000)
committerRalph Boehme <slow@samba.org>
Tue, 26 Jul 2022 13:40:34 +0000 (13:40 +0000)
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 <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/lib/dbwrap/dbwrap_watch.c

index 9d3e44a2728093656a9f06b26bc09e7b13a864bb..029f590825a6e3f396ffa5f7c2951c999296589e 100644 (file)
@@ -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;