1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-28 01:58:17 +03:00

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 <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
Stefan Metzmacher 2022-06-26 12:57:06 +00:00 committed by Ralph Boehme
parent 2129d352ae
commit 908eea1202

View 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;