summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* Fix uClibc build on 64bit platforms by including stdint.hFabrice Fontaine2019-05-194-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes an error detected by buildroot autobuilders: http://autobuild.buildroot.net/results/573/573e2268e205e10d1352fa81122d8f225fdb4575/build-end.log /home/rclinux/rc-buildroot-test/scripts/instance-1/output/host/mips64el-buildroot-linux-uclibc/sysroot/usr/include/stdint.h:122:27: error: conflicting types for 'uintptr_t' typedef unsigned long int uintptr_t; ^ In file included from ../lib/ldb/tests/ldb_msg.c:17:0: ../third_party/cmocka/cmocka.h:126:28: note: previous declaration of 'uintptr_t' was here typedef unsigned int uintptr_t; The define __WORDSIZE is missing when cmocka.h decides how to define uintptr_t, this patch includes stdint.h when needed. Patch sent upstream: https://lists.samba.org/archive/samba-technical/2018-January/125306.html [updated for samba-4.8.4, v2 sent upstream https://lists.samba.org/archive/samba-technical/2018-August/129732.html, updated for samba-4.9.1] Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de> [Retrieved from: https://git.buildroot.net/buildroot/tree/package/samba4/0003-Fix-uClibc-build-on-64bit-platforms-by-including-std.patch] Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com> Reviewed-by: Ralph Böhme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib:util: Add a test for byteorder.hAndreas Schneider2019-05-172-0/+441
| | | | | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Fri May 17 20:44:36 UTC 2019 on sn-devel-184
* lib:util: Move VWV macro to smb_constants.hAndreas Schneider2019-05-171-3/+0
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib:util: Remove PPC big endian asm optimized code in byteorder.hAndreas Schneider2019-05-171-51/+0
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib:util: Remove unused ALIGN marcos from byteorder.hAndreas Schneider2019-05-171-5/+0
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* tdb: Release tdb 1.4.1tdb-1.4.1Andrew Bartlett2019-05-172-1/+74
| | | | | | | | | | | | | * Do not propogate any errors from tdb_repack() to to tdb_transaction_commit() The repack may fail due to lock ordering or memory limits, but the original data has been written so the call must succeed. (bug 13952) Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Fri May 17 08:21:52 UTC 2019 on sn-devel-184
* tdb: Do not return errors from tdb_repack() in the tail of ↵Andrew Bartlett2019-05-171-1/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | tdb_transaction_commit() The call to tdb_repack() inside tdb_transaction_commit() is an optimization, not part of the transaction itself, so failing due to lock or other errors isn't a fatal error that should cause the caller to think the transaction was a failure by returning -1. The tdb transaction itself has finished and been committed onto stable storage via fsync and all locks released at the point tdb_repack() is called. tdb_repack() is only called here as it's a convenient point to attempt to reduce tdb fragmentation without having to add a timer call to repack in all users of tdb. This causes lock ordering issues in Samba, showing up as: ldb: ltdb: tdb(../private/sam.ldb.d/DC=SAMBA2008R2,DC=EXAMPLE,DC=COM.ldb): tdb_transaction_prepare_commit: failed to upgrade hash locks: Locking error This is because Samba has multiple tdb databases open, and the lock order between them is important. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13952 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib:util: Fix tfork return value if sigprocmask failsRikard Falkeborn2019-05-161-1/+1
| | | | | | | | | | | | | | | Returning a non-zero value from a function with bool as return value is the same as returning true. Change the return value to false if sigprocmask or pthread_sigmask fails to indicate failure. Detected with the help of cppcheck. Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Thu May 16 19:08:29 UTC 2019 on sn-devel-184
* lib/crypto: squash 'cast between incompatible function types' warningNoel Power2019-05-161-1/+1
| | | | | | | | | | | To avoid warning above produced by using -Wcast-function-type we; + ensure PyCFunctions of type METH_VARARGS do not declare unused and problematic kargs param. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andreas Schneider <asn@samba.org>
* lib/ldb-samba: squash 'cast between incompatible function types' warningNoel Power2019-05-161-2/+4
| | | | | | | | | | To avoid warning above produced by using -Wcast-function-type we; + ensure PyCFunctions of type METH_NOARGS defined dummy arg Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andreas Schneider <asn@samba.org>
* lib/ldb: Fix incorrect return type for (setter) func typeNoel Power2019-05-161-1/+1
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13948 Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andreas Schneider <asn@samba.org>
* lib/ldb: squash 'cast between incompatible function types' warningNoel Power2019-05-161-45/+94
| | | | | | | | | | | | To avoid warning above produced by using -Wcast-function-type we; + ensure PyCFunctions of type METH_NOARGS defined dummy arg + ensure PyCFunctions of type METH_KEYWORDS use PY_DISCARD_FUNC_SIG macro Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andreas Schneider <asn@samba.org>
* lib/talloc: squash 'cast between incompatible function types' warningNoel Power2019-05-162-5/+12
| | | | | | | | | | To avoid warning above produced by using -Wcast-function-type we; + ensure PyCFunctions of type METH_NOARGS defined dummy arg Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andreas Schneider <asn@samba.org>
* lib/tevent: squash 'cast between incompatible function types' warningNoel Power2019-05-161-23/+50
| | | | | | | | | | | | | | squash 'cast between incompatible function types' warning To avoid warning above produced by using -Wcast-function-type we; + ensure PyCFunctions of type METH_NOARGS defined dummy arg + ensure PyCFunctions of type METH_KEYWORDS use PY_DISCARD_FUNC_SIG macro Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andreas Schneider <asn@samba.org>
* lib/tdb: squash 'cast between incompatible function types' warningNoel Power2019-05-161-20/+40
| | | | | | | | | | | | | | squash 'cast between incompatible function types' warning To avoid warning above produced by using -Wcast-function-type we; + ensure PyCFunctions of type METH_NOARGS defined dummy arg + ensure PyCFunctions of type METH_KEYWORDS use PY_DISCARD_FUNC_SIG macro Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andreas Schneider <asn@samba.org>
* util/charset/torture: ensure each cp850 high bytes is 3 utf8 bytesDouglas Bagnall2019-05-151-0/+52
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* util/charset/convert: do not pretend to reallocDouglas Bagnall2019-05-151-16/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It seems very likely that our clever attempts to dynamically realloc the output buffer were never triggered. Two lines of reasoning lead to this conclusion: 1. We allocate 3 * srclen to start with, but no conversion we use will more than that. To be precise, from 8-bit charsets we will only deal with codepoints in the Unicode basic multilingual plane (up to 0xFFFF). These can all be expressed as 3 or fewer utf-8 bytes. In UTF16 they are naturally 2 bytes, while in the DOS codes they are 1 byte. We have checked the code tables, and can not find a plausible (e.g. not EBCDIC) DOS code page or unix charset that is outside this range. Clients cannot chose the code page, the only code pages we will use come from 'unix charset' and 'dos charset' smb.conf parameters. Therefore the worst that can possibly happen is we expand 1 byte into 3 (specifically, when converting some e.g. CP850 codepoints to UTF-8). 2. If the reallocation was ever used, the results would have been catastrophically wrong, as the input pointer was not reset. Therefore we skip the complication of the goto loop and let E2BIG be just another impossible error to report. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* util/charset/convert: when retrying, retry from the startDouglas Bagnall2019-05-151-1/+2
| | | | | | | | iconv() advances the inbuf pointer; if we decide to realloc and re-iconv, we need to reset inbuf to the source string Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* util/charset/convert: do not overflow dest len in corner caseDouglas Bagnall2019-05-151-2/+2
| | | | | | | | | | | | | | | | | | | Now, if destlen were SIZE_MAX - 1, destlen * 2 would wrap to SIZE_MAX - 3, which makes (destlen * 2 + 2) == SIZE_MAX - 1, the same number again. So we need the <= comparison in this case. As things stand, it is not actually possible for destlen to be SIZE_MAX (because it is always an even number after the first round, and the first round is constrained to be < SIZE_MAX / 2, but *if* destlen was SIZE_MAX, destlen * 2 + 2 would be 0, so that case is OK. Similarly the SIZE_MAX - 2 and smaller cases were covered by the original formula. We add the comment for people who are wondering WTF is going on with all this destlen manipulation. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* util/charset/convert: do not overflow dest lenDouglas Bagnall2019-05-151-1/+10
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* util/charset/convert_string: always set lengthDouglas Bagnall2019-05-151-0/+3
| | | | | | | | | | | In failure cases the destination string pointer is set to NULL, but the size is not changed. Some callers have not been checking the return value and passing the destination pointer and uninitialised length onto other functions. We can curse and blame those callers, but let's also keep them safe. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb: Release ldb 2.0.1Andrew Bartlett2019-05-153-1/+283
| | | | | | | | | | | | | | | | | * Rework pack routines to remove unused features: - ldb_unpack_data_only_attr_list_flags() is removed - LDB_UNPACK_DATA_FLAG_NO_DATA_ALLOC is now always implied This improves the unpack performace significantly. * Improve search performance via new internal flag LDB_UNPACK_DATA_FLAG_READ_LOCKED which removes a memdup * Improve search performance during full scan by ignoring index records early. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* ldb: remove unpack only attr list functionalityAaron Haslett2019-05-154-137/+16
| | | | | | | | | | | | | | | | | Unpack functions currently take an attribute list to restrict the set of attributes to be returned in the constructed message. This functionality is never used and complicates implementation of forthcoming new pack format. This patch removes that functionality. Using the unpack function then filtering the result turns out not to be any slower. NOTE: Configure with --abi-check-disable to build this commit. This patch is part of a set of LDB ABI changes, and the version update is done on the last commit. Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* ldb: move ldb_kv's filter into pack codeAndrew Bartlett2019-05-153-143/+165
| | | | | | | | | | | | | | | | This patch moves ldb_kv's filter code into the pack code to replace 'only attr list' functionality which will be removed in forthcoming commit. Unpacking data then filtering the result is not any slower than the removed 'only attr list' approach. 'only attr list' test repurposed to test unpack -> filter flow. NOTE: Configure with --abi-check-disable to build this commit. This patch is part of a set of LDB ABI changes, and the version update is done on the last commit. Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* ldb: removing msg and dn copying from filter attrsAaron Haslett2019-05-153-49/+66
| | | | | | | | | | | | | | Optimising filter_attrs by removing msg and dn allocation/copying. The caller can construct the msg and possibly steal the dn. Also giving the function an ldb for future use. NOTE: Configure with --abi-check-disable to build this commit. This patch is part of a set of LDB ABI changes, and the version update is done on the last commit. Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* ldb: removing alloc from unpack_dataAaron Haslett2019-05-156-114/+52
| | | | | | | | | | | | Making unpack flag LDB_UNPACK_DATA_FLAG_NO_DATA_ALLOC required behaviour, since allocating data during unpack is slow and unnecessary in all current usages. In any future unpack usage, if editing of returned memory is required, some function that duplicates the message should be used, such as one of the filter_attrs functions, or msg_copy. Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* ldb_kv: Use ldb_msg_add_steal_value() in msg_add_distinguished_name()Andrew Bartlett2019-05-151-66/+14
| | | | | | | This more modern routine allocates a nice talloc tree. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* ldb_kv: Remove incorrect reference to LDB_UNPACK_DATA_FLAG_NO_DNAndrew Bartlett2019-05-151-2/+1
| | | | | | | The DN is now exploded so as to improve other aspects of the search handling. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* ldb_msg: remove_element() checks element array boundsDouglas Bagnall2019-05-101-5/+5
| | | | | | | Previously we half-heartedly checked one end. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb_kv: use ldb_msg_remove_element()Douglas Bagnall2019-05-101-6/+1
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb/tools/ldbtest: initialise msg objectDouglas Bagnall2019-05-101-2/+2
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb_ldap: use ldb_msg API to add elementsDouglas Bagnall2019-05-101-16/+3
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb_ldap: trust db_msg_new() to return empty messageDouglas Bagnall2019-05-101-5/+1
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb: use ldb_msg_new(), not talloc/talloc_zeroDouglas Bagnall2019-05-102-6/+2
| | | | | | | | ldb_msg_new() is currently the same as talloc_zero(), but it might not always be. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* kdb_kv_search: spell 'linearized'Douglas Bagnall2019-05-101-5/+5
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb.h: spelling of 'means'Douglas Bagnall2019-05-101-1/+1
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb.h: improve comment for LDB_ATTR_FLAG_INDEXEDDouglas Bagnall2019-05-101-1/+1
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb modules: paged_search checks control is not NULL (CID 241355)Douglas Bagnall2019-05-091-0/+5
| | | | | | | It is unlikely to be NULL, since we're in the callback. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* ldb_mdb: check fcntl return values (CID 1435851)Douglas Bagnall2019-05-091-1/+10
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* ldb_map: check a return value (CID 241354)Douglas Bagnall2019-05-091-0/+3
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* ldb_ldif: avoid NULL dereference with unexpected arguments (CID 1107195)Douglas Bagnall2019-05-091-1/+1
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* ldb: avoid NULL deref in ldb_dn_from_ldb_val (CID 1034730)Douglas Bagnall2019-05-091-3/+4
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* lib/texpect: avoid theoretical NULL dereference (CID 1273099)Douglas Bagnall2019-05-091-1/+6
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* tdbtool: avoid theoretical NULL dereference (CID 1361462)Douglas Bagnall2019-05-091-9/+11
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* talloc torture: avoid NULL dereferenceDouglas Bagnall2019-05-091-1/+3
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* dbwrap: Adapt tdb_data_buf's overflow handling to modern conventionsVolker Lendecke2019-05-081-4/+2
| | | | | | | | This is the way we do it right now, avoid confusion why "tmp" might be needed Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap: Fix tdb_data_buf()Volker Lendecke2019-05-081-1/+1
| | | | | | | IIRC there are platforms that don't like memcpy() with len=0. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib:torture: Fix string comparison macros where we directly pass NULLAndreas Schneider2019-05-081-3/+5
| | | | | | | | | See e.g. lib/util/tests/strlist.c +177 Found by GCC 9. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib:crypto: Remove unused SHA512Andreas Schneider2019-05-074-340/+1
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* talloc: Follow pattern of ldb and tdb to ensure "make test" depends on a buildAndrew Bartlett2019-05-061-1/+7
| | | | | Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>