]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:dbwrap: Fix zeroing wrec->added
authorAndreas Schneider <asn@samba.org>
Tue, 9 Jun 2026 09:52:10 +0000 (11:52 +0200)
committerAnoop C S <anoopcs@samba.org>
Fri, 12 Jun 2026 08:25:34 +0000 (08:25 +0000)
In file included from source3/include/includes.h:23,
                 from source3/lib/dbwrap/dbwrap_watch.c:20:
source3/lib/dbwrap/dbwrap_watch.c: In function ‘dbwrap_watched_watch_remove_instance’:
lib/replace/replace.h:850:24: error: ‘memset_explicit’ writing 32 bytes into a
region of size 24 overflows the destination [-Werror=stringop-overflow=]

GCC 15's -Wstringop-overflow analysis of memset_explicit (via the ZERO_STRUCT
macro) tracks the pointer through the (char *) cast and misidentifies the
destination as the first member pid (24 bytes) rather than the enclosing struct
dbwrap_watcher (32 bytes). This is a GCC false positive.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/lib/dbwrap/dbwrap_watch.c

index e62aba91090ae240b76fe70835c51c02adf8b13c..f02401d1855ab07b7d2903bee62b3473c10a3845 100644 (file)
@@ -970,7 +970,7 @@ void dbwrap_watched_watch_remove_instance(struct db_record *rec, uint64_t instan
                DBG_DEBUG("Watcher %s:%"PRIu64" reverted from adding\n",
                          server_id_str_buf(clear_watcher.pid, &buf),
                          clear_watcher.instance);
-               ZERO_STRUCT(wrec->added);
+               wrec->added = (struct dbwrap_watcher) { 0 };
        }
 
        for (i=0; i < wrec->watchers.count; i++) {