summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* lib tdb: memcmp ubsan warningGary Lockyer2019-07-011-5/+7
| | | | | | | | | | | | | | | | | Fix the ubsan warning lib/tdb/common/tdb.c:184:9: runtime error: null pointer passed as argument 2, which is declared to never be null" memcmp call now guarded by a length check. memcmp returns zero when called with a zero length parameter. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org> Autobuild-User(master): Noel Power <npower@samba.org> Autobuild-Date(master): Mon Jul 1 14:50:54 UTC 2019 on sn-devel-184
* lib/krb5_wrap: clang: Fix warning: Null pointer passed as an argumentNoel Power2019-07-011-1/+1
| | | | | | | | | | | Fixes: lib/krb5_wrap/krb5_samba.c:3241:3: warning: Null pointer passed as an argument to a 'nonnull' parameter <--[clang] memcpy(gss_cksum + 28, in_data->data, orig_length); ^ Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* lib/krb5_wrap: clang: Fix warning: Call to function 'mktemp' is insecureNoel Power2019-07-011-1/+1
| | | | | | | | | | | Fixes: lib/krb5_wrap/krb5_samba.c:2012:2: warning: Call to function 'mktemp' is insecure as it always creates or uses insecure temporary file. Use 'mkstemp' instead <--[clang] mktemp(tmp_name); ^~~~~~ Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* lib/util: clang: Fix warning: Value stored to 'ret' is never read warningNoel Power2019-07-011-1/+1
| | | | | | | | | | | Fixes: lib/util/server_id_db.c:181:3: warning: Value stored to 'ret' is never read <--[clang] ret = tdb_store(tdb, key, talloc_tdb_data(ids), TDB_MODIFY); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* lib/ldb/common: clang: Fix Value stored to 'ret' is never read warningNoel Power2019-07-011-1/+0
| | | | | | | | | | | | Fixes: lib/ldb/common/ldb.c:1091:3: warning: Value stored to 'ret' is never read <--[clang] ret = 0; ^ ~ 1 warning generated. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* lib/tdb/common: Fix Array access results in a null pointer dereferenceNoel Power2019-07-011-1/+2
| | | | | | | | | | | | Fixes; lib/tdb/common/transaction.c:613:7: warning: Array access (via field 'blocks') results in a null pointer dereference <--[clang] if (tdb->transaction->blocks[i] != NULL) { ^ 1 warning generated. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* lib/tdb/common: Fix warning: Null pointer passed as argument to paramNoel Power2019-07-011-2/+4
| | | | | | | | | | | Fixes: lib/tdb/common/rescue.c:299:2: warning: Null pointer passed as an argument to a 'nonnull' parameter <--[clang] qsort(found.arr, found.num, sizeof(found.arr[0]), cmp_key); ^ ~~~~~~~~~ Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* lib/util: Fix Value stored to 'ret' is never read warningNoel Power2019-07-011-1/+1
| | | | | | | | | Fixes: lib/util/tfork.c:260:3: warning: Value stored to 'ret' is never read <--[clang] Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* util: Fix signed/unsigned comparisons by castingMartin Schwenke2019-07-015-8/+10
| | | | | | | | | | | One case needs a variable declared, so it can be compared to -1 and then cast to size_t for comparison. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Mon Jul 1 08:00:29 UTC 2019 on sn-devel-184
* util: Fix signed/unsigned comparisons by declaring as size_tMartin Schwenke2019-07-011-8/+8
| | | | | | | | I may be missing something subtle but I can't see a reason for declaring these as ssize_t. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Andreas Schneider <asn@samba.org>
* util: Fix signed/unsigned comparisons by declaring as size_tMartin Schwenke2019-07-013-6/+6
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Andreas Schneider <asn@samba.org>
* tests-util: Adding test to verify "allow no conversion" flagSwen Schillig2019-06-301-0/+33
| | | | | | | | | | | | | | | | | | The internal string conversion routines smb_strtoul(l) return an error if the provided string could not be converted to an integer. This can be the case if the string is empty or if it starts with non-numeric characters which cannot be converted. The standard C library, however, does allow this and simply returns 0 as the converted value. If this behaviour is wanted, it can be enabled by using the "SMB_STR_ALLOW_NO_CONVERSION" flag. Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org> Autobuild-User(master): Ralph Böhme <slow@samba.org> Autobuild-Date(master): Sun Jun 30 12:47:24 UTC 2019 on sn-devel-184
* tests-util: Adding test to verify "full-string-conversion" flagSwen Schillig2019-06-301-0/+28
| | | | | | | | | | | | The standard string to integer conversion routines stop at the first character which cannot be converted to a number. However, if such a character is found, it is not considered an error. With the flag "SMB_STR_FULL_STR_CONV" enabled, an error will be returned if the string could not be converted entirely. Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* tests-util: Adding test to verify "allow-negative" flagSwen Schillig2019-06-301-0/+38
| | | | | | | | | | | | | | | The standard string to integer conversion routines allow strings with a leading "-" to indicate a negative number. However, the returned value is always an unsigned value representing the bit-pattern of this negative value. Typically, this behaviour is NOT wanted and therefore the standard behavior of the internal smb_strtoul(l) return an erros in such situations. It can be enabled though by using the flag SMB_STR_ALLOW_NEGATIVE. This test verifies the correct processing. Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* util: cleanup API change for strtoul(l) wrappersSwen Schillig2019-06-301-5/+0
| | | | | | Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* lib: Update all consumers of strtoul_err(), strtoull_err() to new APISwen Schillig2019-06-307-55/+63
| | | | | | Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* lib: Add capability to enable standard glibc behaviour for string to int ↵Swen Schillig2019-06-301-10/+16
| | | | | | | | | | | | conversion Adding two addtl. flags SAMBA_STR_ALLOW_NO_CONVERSION and SAMBA_STR_GLIBC_STANDARD for the wrappers strtoul_err() and strtoull_err() providing the possibility to get standard glibc behaviour for string to integer conversion. Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* lib: Add check for full string consumption when converting string to intSwen Schillig2019-06-301-0/+22
| | | | | | | | | | Some callers want to have the entire string being used for a string to integer conversion, otherwise flag an error. This is possible by providing the SAMBA_STR_FULL_STR_CONV flag. Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* lib: Prepare for strtoul_err(), strtoull_err() API changeSwen Schillig2019-06-302-12/+31
| | | | | | | | | In order to still be bisectable when changing the API for the wrappers strtoul_err() and strtoull_err() some preparations need to be performed. Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* lib: Add flag definitions to control the internal string to int conversion ↵Swen Schillig2019-06-301-0/+7
| | | | | | | | | | | | | | | | routines The following flags are defined intially SMB_STR_STANDARD # raise error if negative or non-numeric SMB_STR_ALLOW_NEGATIVE # allow strings with a leading "-" SMB_STR_FULL_STR_CONV # entire string must be converted SMB_STR_ALLOW_NO_CONVERSION # allow empty strings or non-numeric SMB_STR_GLIBC_STANDARD # act exactly as the standard glibc strtoul Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* tests-util: Adding test to verify "no-conversion" detectionSwen Schillig2019-06-301-0/+28
| | | | | | | | | | | | The standard string to integer conversion routines return zero if a string was to be converted which did not reflect a number. It is not flag'ed as an error. The wrapper functions strtoul_err() and strtoull_err() are expected to exactly do this. Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* tests-util: Adding test to verify negative "number" detectionSwen Schillig2019-06-301-0/+37
| | | | | | | | Verify that a string representing a negative number is throwing an error. Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* tests-util: Adding strtoul(l)_err() test leaving errno untouchedSwen Schillig2019-06-301-0/+29
| | | | | | | | | | | The wrapper functions strtoul_err() and strtoull_err() trigger other functions/routines which modify errno. However, callers of those wrapper functions expect errno to be unchanged. This test verifies the expectation. Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* lib/crypto: Use GnuTLS RC4 for samba_gnutls_arcfour_confounded_md5()Andrew Bartlett2019-06-273-11/+35
| | | | | | | This allows Samba to use GnuTLS for drsuapi_{en,de}crypt_attribute_value() Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* lib/crypto: Add GnuTLS helper function samba_gnutls_arcfour_confounded_md5()Andrew Bartlett2019-06-273-2/+85
| | | | | | | | This will avoid duplicated code as we convert arcfour_crypt_blob() into direct GnuTLS calls Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* libcli:util: Add gnutls_error_to_werror()Andreas Schneider2019-06-272-0/+56
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib/crypto: move gnutls error wrapper to own subsystemAndrew Bartlett2019-06-273-0/+104
| | | | | Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* lib/param: clang: Fix 'dereference of a null pointer' warningNoel Power2019-06-261-1/+1
| | | | | | | | | | | | | Fixes: lib/param/loadparm.c:3325:36: warning: Access to field 'szService' results in a dereference of a null pointer (loaded from variable 'service') <--[clang] return lpcfg_string((const char *)service->szService) Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz> Autobuild-User(master): Noel Power <npower@samba.org> Autobuild-Date(master): Wed Jun 26 11:53:08 UTC 2019 on sn-devel-184
* lib/dwrap: Fix 'Null pointer passed as an argument to a 'nonnull' parameter 'Noel Power2019-06-261-1/+1
| | | | | | | | | | Fixes: lib/dbwrap/dbwrap.c:645:4: warning: Null pointer passed as an argument to a 'nonnull' parameter <--[clang] memcpy(p, dbufs[i].dptr, thislen); Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* lib/dbwrap: clang: Fix 'all argument is an uninitialized value'Noel Power2019-06-261-2/+3
| | | | | | | | | | | Fixes: lib/dbwrap/dbwrap.c:533:4: warning: 2nd function call argument is an uninitialized value <--[clang] dbwrap_lock_order_unlock(db, lockptr); ^ Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* lib/util: clang: Fix Value stored during its initialization is never readNoel Power2019-06-261-1/+4
| | | | | | | | | Fixes: lib/util/util_tdb.c:385:11: warning: Value stored to 'result' during its initialization is never read <--[clang] Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* clang: Fix Null pointer passed as argument warningNoel Power2019-06-261-1/+1
| | | | | | | | | | Fixes: lib/tdb/common/transaction.c:354:2: warning: Null pointer passed as an argument to a 'nonnull' parameter <--[clang] memcpy(tdb->transaction->blocks[blk] + off, buf, len); & Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* lib/tdb: clang: Fix warning: Dereference of null pointerNoel Power2019-06-261-0/+3
| | | | | | | | | | | Fixes: lib/tdb/common/lock.c:933:6: warning: Dereference of null pointer <--[clang] if (tdb->allrecord_lock.count) { ^~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* py3: Remove duplicated PyUnicode_Check() after the py3 compat macros were ↵Andrew Bartlett2019-06-243-3/+3
| | | | | | | | | | | | removed This came about because in py2 we had to check for strings and unicode. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <noel.power@suse.com> Autobuild-User(master): Noel Power <npower@samba.org> Autobuild-Date(master): Mon Jun 24 18:48:53 UTC 2019 on sn-devel-184
* py3: Remove PyStr_AsUTF8AndSize() compatability macroAndrew Bartlett2019-06-241-16/+5
| | | | | | | | We no longer need Samba to be py2/py3 compatible so we choose to return to the standard function names. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <noel.power@suse.com>
* py3: Remove PyStr_AsUTF8() compatability macroAndrew Bartlett2019-06-243-21/+10
| | | | | | | | We no longer need Samba to be py2/py3 compatible so we choose to return to the standard function names. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <noel.power@suse.com>
* py3: Remove PyStr_FromFormatV() compatability macroAndrew Bartlett2019-06-241-3/+1
| | | | | | | | We no longer need Samba to be py2/py3 compatible so we choose to return to the standard function names. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <noel.power@suse.com>
* py3: Remove PyStr_FromFormat() compatability macroAndrew Bartlett2019-06-243-18/+7
| | | | | | | | We no longer need Samba to be py2/py3 compatible so we choose to return to the standard function names. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <noel.power@suse.com>
* py3: Remove PyStr_FromStringAndSize() compatability macroAndrew Bartlett2019-06-241-4/+2
| | | | | | | | We no longer need Samba to be py2/py3 compatible so we choose to return to the standard function names. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <noel.power@suse.com>
* py3: Remove PyStr_FromString() compatability macroAndrew Bartlett2019-06-243-32/+26
| | | | | | | | We no longer need Samba to be py2/py3 compatible so we choose to return to the standard function names. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <noel.power@suse.com>
* py3: Remove PyStr_Check() compatability macroAndrew Bartlett2019-06-243-9/+3
| | | | | | | | We no longer need Samba to be py2/py3 compatible so we choose to return to the standard function names. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <noel.power@suse.com>
* lib ldb key value: use TALLOC_FREE() per README.CodingGary Lockyer2019-06-211-8/+8
| | | | | | | | | Signed-off-by: Andrew Bartlett <abartlet@samba.org> Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Fri Jun 21 05:45:02 UTC 2019 on sn-devel-184
* lib ldb key value: fix index bufferingGary Lockyer2019-06-214-48/+415
| | | | | | | | | | | | | | As a performance enhancement the key value layer maintains a cache of the index records, which is written to disk as part of a prepare commit. This patch adds an extra cache at the operation layer to ensure that the cached indexes remain consistent in the event of an operation failing. Add test to test for index corruption in a failed modify. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org> Signed-off-by: Andrew Bartlett <abartlet@samba.org>
* lib ldb key value: Remove check_parent from ldb_kv_index_idxptr()Gary Lockyer2019-06-211-11/+4
| | | | | | | | | | | | | | The callers will soon have two possible parents for this pointer, so we need to remove this check, which was added out of caution given the rather strange pattern of putting an active memory pointer into a TDB (as a hash map). That is, the only callers that did call this with "true" would have to call this with "false", so just remove the complexity. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib ldb ldb_key_value tests: Add tests for wrapped operationsGary Lockyer2019-06-216-2/+1112
| | | | | | | | Add test exercising the sub/nested transactions wrapping the key value operations. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib ldb key value: add nested transaction support.Gary Lockyer2019-06-212-16/+179
| | | | | | | | | | Use the nested transaction support added to the key value back ends to make key value operations atomic. This will ensure that rename operation failures, which delete the original record and add a new record, leave the database in a consistent state. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib ldb key value backends: Add nested txn supportGary Lockyer2019-06-213-0/+69
| | | | | | | | | | Add limited nested transaction support to the back ends to make the key value operations atomic (for those back ends that support nested transactions). Note: that only the lmdb backend currently supports nested transactions. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib ldb tests: remove deprecation warning from api.pyGary Lockyer2019-06-211-15/+15
| | | | | | | | Remove the "DeprecationWarning: Please use assertEqual instead." warnings from api.py Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib ldb tests: Test nested transactionsGary Lockyer2019-06-211-0/+103
| | | | | | | | Add a test to document that ldb does not currently support nested transactions. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* tevent: Fix a typoVolker Lendecke2019-06-201-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>