1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00
Commit Graph

90 Commits

Author SHA1 Message Date
Volker Lendecke
9d7c7357a4 lib: Add tdb_data_dbg()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2023-01-10 00:28:37 +00:00
Noel Power
5477b83db2 s3/lib: don't write to buffer (which might be NULL) if bufsize <=0
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>
2019-05-29 10:10:23 +00:00
Andreas Schneider
2b2edccb5a s3:lib: Fix undefined behavior in tdb_unpack()
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-04 00:23:02 +01:00
Andreas Schneider
86592673fb s3:lib: Fix undefined behavior in tdb_pack()
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-03 21:16:31 +01:00
Andreas Schneider
4e9b3ed412 s3:lib: Fix uninitialized variable
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-12-03 21:16:31 +01:00
Volker Lendecke
94f8a690f6 lib: Remove unused tdb_trans_* functions
The transactions have all moved to dbwrap

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-10-27 21:24:24 +02:00
Volker Lendecke
ba787dc4ad tdb_unpack: Protect against overflow
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-10-08 22:17:09 +02:00
Volker Lendecke
0c0c79b32e tdb_unpack: Correct "len" arg for "B" format
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-08 22:17:09 +02:00
Volker Lendecke
8f211efb3a tdb_unpack: Convert to size_t for internal calculations
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-10-08 22:17:09 +02:00
Volker Lendecke
826a212771 lib: Remove unused tdb_pack_append()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-10-03 01:07:15 +02:00
Amitay Isaacs
e9b8751b58 s3-lib: Fix format-nonliteral warning
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-24 01:33:50 +02:00
Amitay Isaacs
a37048f8d4 s3-lib: Pass missing argument for format string
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>
2016-08-18 19:51:10 +02:00
Richard Sharpe
dffe228283 Convert all uint32/16/8 to _t in source3/lib.
Signed-off-by: Richard Sharpe <rsharpe@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2015-05-13 19:11:23 +02:00
Volker Lendecke
47795aef9d lib: Remove tdb_open_compat
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-03-17 11:30:51 +01:00
Volker Lendecke
5454f71fc0 lib: Move tdb lock timeout fns to source3
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>
2014-09-18 20:36:11 +02:00
Gregor Beck
037f57e12f util_tdb: add function tdb_data_string()
Signed-off-by: Gregor Beck <gbeck@sernet.de>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2013-04-18 13:15:11 +02:00
David Disseldorp
e4505fc27b tdb: return unpack error on strdup failure
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-08-31 21:05:21 +02:00
Rusty Russell
fc9b298761 util_tdb: move timeout chainlock variants from source3/lib/util/util_tdb.c
We're about to use them for dbwrap.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-06-22 07:35:17 +02:00
Rusty Russell
6244f668a3 TDB2: make SAMBA use tdb1 again for the moment.
Otherwise the following surgery will break the SAMBA build and testsuite.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-06-19 05:38:05 +02:00
Andrew Bartlett
cc86f8e985 lib/util: Move map_nt_error_from_tdb to the top level
This will help with making dbwrap available as a top level library.

Andrew Bartlett
2012-04-18 12:04:59 +10:00
Rusty Russell
26ce47ecc0 util_tdb: return -1/0 from lock_with_timeout functions.
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-14 08:13:28 +09:30
Rusty Russell
376511ed4d tdb_compat: adapt to tdb2 API change.
Add the ecode arg to all the log functions, and log it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-09-14 07:13:13 +09:30
Michael Adam
0aa85ec43a s3:lib: fix a comment in tdb_unpack() 2011-08-15 17:15:15 +02:00
Gregor Beck
8a36e72140 s3: avoid reading past the end of buffer in tdb_unpack 'f' if zero termination is missing
Signed-off-by: Michael Adam <obnox@samba.org>
2011-08-15 17:15:14 +02:00
Gregor Beck
39f9c854ae s3: avoid reading past the end of buffer in tdb_unpack 'P' if zero termination is missing
Signed-off-by: Michael Adam <obnox@samba.org>
2011-08-15 17:15:14 +02:00
Rusty Russell
cd96271036 source3/lib/util_tdb.c: operation timeout support for TDB2.
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-20 11:18:35 +02:00
Rusty Russell
d925b327f4 tdb_compat: Higher level API fixes.
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-20 11:18:35 +02:00
Rusty Russell
ca1936fbb2 tdb_compat: use tdb_open_compat.
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-20 11:18:35 +02:00
Rusty Russell
4823262439 tdb2: #ifdef out TDB_ERR_NOLOCK and TDB_ERR_LOCK_TIMEOUT.
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-20 11:18:35 +02:00
Rusty Russell
868d77bc5b tdb_chainlock: check returns for 0, not -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-20 11:18:35 +02:00
Rusty Russell
d6251996fa tdb_transaction_cancel: ignore return value.
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-20 11:18:35 +02:00
Andrew Bartlett
73b377432c s3-talloc Change TALLOC_REALLOC_ARRAY() to talloc_realloc()
Using the standard macro makes it easier to move code into common, as
TALLOC_REALLOC_ARRAY isn't standard talloc.

Andrew Bartlett
2011-06-09 12:40:08 +02:00
Günther Deschner
d8cfca3a9b s3: only include tdb headers where needed.
Guenther
2011-05-06 10:48:10 +02:00
Andrew Bartlett
1475013963 lib/util Move source3 tdb_wrap_open() into the common code.
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-05-06 07:51:24 +02:00
Günther Deschner
0e771263ee s3-includes: only include system/filesys.h when needed.
Guenther
2011-03-30 01:13:07 +02:00
Volker Lendecke
2111fe5255 s3: Use a switch to implement map_nt_error_from_tdb
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-14 17:42:49 +01:00
Volker Lendecke
cfc44d2441 s3: Make tdb_wrap_open more robust
This hides the use of talloc_reference from the caller, making it impossible to
wrongly call talloc_free() on the result.
2010-03-13 20:20:37 +01:00
Andreas Schneider
c6c21f489d s3-lib: Remove obsolete signal type cast. 2010-02-23 12:23:43 +01:00
Volker Lendecke
8300b255a5 Fix some nonempty blank lines 2009-08-07 13:02:15 +02:00
Volker Lendecke
ed87594e5f Add tdb_data_cmp 2009-07-15 10:55:20 +02:00
Michael Adam
59859b547c s3: separate tdb validation code out into its own source file
So this gets now linked only into its single user: winbindd
(needed by winbindd_cache.c)

Michael
2009-01-28 09:43:57 +01:00
Volker Lendecke
fe9dd8710d Remove unused tdb_search_keys() 2009-01-19 00:05:56 +01:00
Günther Deschner
64d8eb0cee s3-util: for convenience, provide format comments in tdb_unpack().
Guenther
2009-01-16 00:28:45 +01:00
Jeremy Allison
c07ea13d30 Fix race condition in alarm lock processing noticed by Richard Sharpe <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.
2009-01-08 10:36:10 -08:00
Jelmer Vernooij
7d371c684d Sync util_tdb implementations. 2008-10-12 16:53:17 +02:00
Michael Adam
8be49cdd3e util_tdb: fix a segfault caused by a fatal typo.
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 d9bd894c2e)
2008-04-12 01:36:10 +02:00
Michael Adam
f1c844c168 util_tdb: remove trivial and unused tdb_wipe().
It has been replaced by tdb_wipe_all().

Michael
(This used to be commit cdde2e4eac)
2008-03-26 11:15:03 +01:00
Michael Adam
6efe4873dc util_tdb: make the _byblob fetch/store functions public again.
Users of these are currently being written...

Michael
(This used to be commit 1c51bec531)
2008-03-26 10:50:35 +01:00
Michael Adam
6fa39aa87d util_tdb: add my (C) for the tdb validation code
Michael
(This used to be commit abf02a5a14)
2008-03-25 15:55:34 +01:00
Michael Adam
aaa5971315 util_tdb: add a wrapper tdb_wipe() for traverse with tdb_traverse_delete_fn().
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 d4be4e30cd)
2008-03-25 15:55:34 +01:00