summaryrefslogtreecommitdiff
path: root/source3/lib/util_tdb.c
AgeCommit message (Collapse)AuthorFilesLines
2023-01-10lib: Add tdb_data_dbg()Volker Lendecke1-0/+5
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-05-29s3/lib: don't write to buffer (which might be NULL) if bufsize <=0Noel Power1-6/+7
Some code depends that tdb_pack[va] will return the bytes it would write to 'buf' if the bufsize passed in is <=0, writing to the buffer is protected by with lines like if (bufsize && bufsize >= len) { /* write to 'buf' */ } however in these instances the local pointer to the buffer is still modified buf += len; It's quite probable if bufsize == 0 that buf itself is NULL, in this case we should protect against performing pointer arithmetic. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andreas Schneider <asn@samba.org>
2018-12-04s3:lib: Fix undefined behavior in tdb_unpack()Andreas Schneider1-8/+14
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz> Autobuild-User(master): Gary Lockyer <gary@samba.org> Autobuild-Date(master): Tue Dec 4 00:23:03 CET 2018 on sn-devel-144
2018-12-03s3:lib: Fix undefined behavior in tdb_pack()Andreas Schneider1-7/+6
util_tdb.c:98:5: runtime error: null pointer passed as argument 2, which is declared to never be null This means the second argument of memcpy() can't be NULL. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2018-12-03s3:lib: Fix uninitialized variableAndreas Schneider1-1/+1
util_tdb.c:116:7: error: ‘len’ may be used uninitialized in this function [-Werror=maybe-uninitialized] buf += len; ^~ ../../source3/lib/util_tdb.c:44:6: note: ‘len’ was declared here int len; ^~~ Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2018-10-27lib: Remove unused tdb_trans_* functionsVolker Lendecke1-66/+0
The transactions have all moved to dbwrap Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-10-08tdb_unpack: Protect against overflowVolker Lendecke1-0/+3
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-10-08tdb_unpack: Correct "len" arg for "B" formatVolker Lendecke1-2/+2
All but one of the users of the "B" format specifier passed in a pointer to uint32_t instead of what tdb_unpack expected, an "int". Because this is a purely internal API, change the tdb_unpack function and adjust that one caller. To reviewers: Please check carefully, thanks :-) Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-10-08tdb_unpack: Convert to size_t for internal calculationsVolker Lendecke1-4/+4
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-10-03lib: Remove unused tdb_pack_append()Volker Lendecke1-34/+0
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2016-08-24s3-lib: Fix format-nonliteral warningAmitay Isaacs1-0/+3
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12168 Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2016-08-18s3-lib: Pass missing argument for format stringAmitay Isaacs1-1/+1
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12163 Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Volker Lendecke <vl@samba.org>
2015-05-13Convert all uint32/16/8 to _t in source3/lib.Richard Sharpe1-20/+20
Signed-off-by: Richard Sharpe <rsharpe@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2015-03-17lib: Remove tdb_open_compatVolker Lendecke1-2/+3
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-18lib: Move tdb lock timeout fns to source3Volker Lendecke1-0/+78
This is not the nicest code and needs to be replaced. Remove it from common. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
2013-04-18util_tdb: add function tdb_data_string()Gregor Beck1-0/+33
Signed-off-by: Gregor Beck <gbeck@sernet.de> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2012-08-31tdb: return unpack error on strdup failureDavid Disseldorp1-0/+3
Signed-off-by: Lars Müller <lars@samba.org> Autobuild-User(master): David Disseldorp <ddiss@samba.org> Autobuild-Date(master): Fri Aug 31 21:05:21 CEST 2012 on sn-devel-104
2012-06-22util_tdb: move timeout chainlock variants from source3/lib/util/util_tdb.cRusty Russell1-81/+0
We're about to use them for dbwrap. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-06-19TDB2: make SAMBA use tdb1 again for the moment.Rusty Russell1-106/+0
Otherwise the following surgery will break the SAMBA build and testsuite. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-04-18lib/util: Move map_nt_error_from_tdb to the top levelAndrew Bartlett1-58/+0
This will help with making dbwrap available as a top level library. Andrew Bartlett
2011-09-14util_tdb: return -1/0 from lock_with_timeout functions.Rusty Russell1-2/+2
Keeps the tdb2 API change (which returns error codes, rather than -1) localized. The function returns -1 down the other path, so make it consistent. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-09-14tdb_compat: adapt to tdb2 API change.Rusty Russell1-3/+4
Add the ecode arg to all the log functions, and log it. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-08-15s3:lib: fix a comment in tdb_unpack()Michael Adam1-1/+1
2011-08-15s3: avoid reading past the end of buffer in tdb_unpack 'f' if zero ↵Gregor Beck1-1/+1
termination is missing Signed-off-by: Michael Adam <obnox@samba.org>
2011-08-15s3: avoid reading past the end of buffer in tdb_unpack 'P' if zero ↵Gregor Beck1-1/+3
termination is missing Signed-off-by: Michael Adam <obnox@samba.org>
2011-06-20source3/lib/util_tdb.c: operation timeout support for TDB2.Rusty Russell1-0/+96
TDB2 doesn't have (the racy) signal pointer; the new method is to override the locking callbacks and do the timeout internally. The technique here is to invalidate the struct flock when the timeout occurs, so it works even if it happens before we enter the fcntl() call. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-06-20tdb_compat: Higher level API fixes.Rusty Russell1-3/+3
My previous patches fixed up all direct TDB callers, but there are a few utility functions and the db_context functions which are still using the old -1 / 0 return codes. It's clearer to fix up all the callers of these too, so everywhere is consistent: non-zero means an error. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-06-20tdb_compat: use tdb_open_compat.Rusty Russell1-6/+11
This is a helper for the common case of opening a tdb with a logging function, but it doesn't do all the work, since TDB1 and TDB2's log functions are different types. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-06-20tdb2: #ifdef out TDB_ERR_NOLOCK and TDB_ERR_LOCK_TIMEOUT.Rusty Russell1-0/+4
These don't exist in tdb2. The former is used in one weird place in tdb1, and the latter not at all. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-06-20tdb_chainlock: check returns for 0, not -1.Rusty Russell1-1/+1
TDB2 returns a negative error number on failure. This is compatible if we always check for != 0 instead of == -1. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-06-20tdb_transaction_cancel: ignore return value.Rusty Russell1-6/+2
TDB2 returns void here. tdb_transaction_cancel will *always* return with the transaction cancelled, but it will complain via the log function if a transaction wasn't in progress. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-06-09s3-talloc Change TALLOC_REALLOC_ARRAY() to talloc_realloc()Andrew Bartlett1-1/+1
Using the standard macro makes it easier to move code into common, as TALLOC_REALLOC_ARRAY isn't standard talloc. Andrew Bartlett
2011-05-06s3: only include tdb headers where needed.Günther Deschner1-0/+2
Guenther
2011-05-06lib/util Move source3 tdb_wrap_open() into the common code.Andrew Bartlett1-159/+0
This #if _SAMBA_BUILD == 3 is very unfortunate, as it means that in the top level build, these options are not available for these databases. However, having two different tdb_wrap lists is a worse fate, so this will do for now. Andrew Bartlett
2011-03-30s3-includes: only include system/filesys.h when needed.Günther Deschner1-0/+1
Guenther
2010-03-14s3: Use a switch to implement map_nt_error_from_tdbVolker Lendecke1-30/+47
First, this immediately gave me the warning that TDB_ERR_NESTING was not covered and second, this saved 48 bytes in the .o :-)
2010-03-13s3: Make tdb_wrap_open more robustVolker Lendecke1-41/+87
This hides the use of talloc_reference from the caller, making it impossible to wrongly call talloc_free() on the result.
2010-02-23s3-lib: Remove obsolete signal type cast.Andreas Schneider1-3/+3
2009-08-07Fix some nonempty blank linesVolker Lendecke1-7/+7
2009-07-15Add tdb_data_cmpVolker Lendecke1-0/+19
2009-01-28s3: separate tdb validation code out into its own source fileMichael Adam1-484/+0
So this gets now linked only into its single user: winbindd (needed by winbindd_cache.c) Michael
2009-01-19Remove unused tdb_search_keys()Volker Lendecke1-68/+0
2009-01-16s3-util: for convenience, provide format comments in tdb_unpack().Günther Deschner1-7/+7
Guenther
2009-01-08Fix race condition in alarm lock processing noticed by Richard Sharpe ↵Jeremy Allison1-1/+1
<realrichardsharpe@gmail.com>. "It seems to me that if the lock is already held by another process when we enter this code, there is a race between the timeout and the granting. If the lock is subsequently granted, the process releasing the lock will signal the wait variable (or whatever) and our process will be scheduled. However, if the timeout occurs before we are scheduled, the timeout will be delivered first. We will have the lock but will forget we have the lock, and never release it." Jeremy.
2008-10-12Sync util_tdb implementations.Jelmer Vernooij1-297/+0
2008-04-12util_tdb: fix a segfault caused by a fatal typo.Michael Adam1-1/+1
In tdb_wrap_log(), in on occurrence of "debug_level = 0" instead of "debuglevel = 0" caused me segfaults when accessing DEBUGLEVEL (which is defined as "*debug_level"...) Michael (This used to be commit d9bd894c2ec4faf87e8ff96e27c7e2b8175f9387)
2008-03-26util_tdb: remove trivial and unused tdb_wipe().Michael Adam1-17/+0
It has been replaced by tdb_wipe_all(). Michael (This used to be commit cdde2e4eaca51d51f036ad99d55df7bfd6535b03)
2008-03-26util_tdb: make the _byblob fetch/store functions public again.Michael Adam1-4/+4
Users of these are currently being written... Michael (This used to be commit 1c51bec5318bad085c09931aa7e8f72f41d103fe)
2008-03-25util_tdb: add my (C) for the tdb validation codeMichael Adam1-0/+1
Michael (This used to be commit abf02a5a142c55d9e0053d319c867e4fcc3e6c30)
2008-03-25util_tdb: add a wrapper tdb_wipe() for traverse with tdb_traverse_delete_fn().Michael Adam1-2/+8
Replace all callers of traverse with this tdb_traverse_delete_fn() and don't export tdb_traverse_delete_fn() anymore. Michael (This used to be commit d4be4e30cd8c3bdc303da30e42280f892a45a8c9)