summaryrefslogtreecommitdiff
path: root/lib/talloc
AgeCommit message (Collapse)AuthorFilesLines
2025-11-11Replace memset_s() with memset_explicit()Andreas Schneider1-1/+1
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2025-09-02lib: Add talloc_realloc_zero()talloc-2.4.4Volker Lendecke5-1/+150
Like talloc_realloc, zeroing out expanded memory Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2025-08-14lib: docs: talloc: fix a wrong cd commandMichael Adam1-1/+1
Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org> Autobuild-User(master): Anoop C S <anoopcs@samba.org> Autobuild-Date(master): Thu Aug 14 06:27:38 UTC 2025 on atb-devel-224
2025-08-14lib:talloc: Remove obsolete web pageAndreas Schneider1-51/+0
The current one is the doxygen generated one. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
2025-02-06talloc: version 2.4.3talloc-2.4.3Jule Anger3-1/+83
* Testsuite and documenation fixes * Add LGPLv3 LICENSE file Signed-off-by: Jule Anger <janger@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
2025-02-05talloc: Add a comment explaining talloc_asprintf_addbuf()Volker Lendecke1-0/+4
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2025-01-02replace direct calls to memset_s() with commonly used macrosMichael Tokarev1-1/+1
samba provides macros for zeroing various structures in memory, and all code uses them instead of relying on memset_s(). However, a few places use memset_s() directly. Replace these usages with macros for consistency and to be able to replace memset_s() easier. A few notes. Commit 03a50d8f7d872b6ef701d12 "lib:util: Check memset_s() error code in talloc_keep_secret_destructor()" (Aug-2022) added a check for error return from memset_s(). This is the only place in whole codebase which bothers about doing this. But I've difficult time figuring out the intention. Was there a real case when this code path is actually executed? Commit 7658c9bf0a9c99e3f200571 "lib:crypto: Remove redundant array zeroing" (Nov-2023) removed the OTHER line from the two lines used to zero memory in here. Initially the code used both memset_s() *and* ZERO_ARRAY_LEN(), the former has been removed. This change removes the other - memset_s(), reintroducing ZERO_ARRAY_LEN(). Here however, it's probably better to use BURN_PTR instead of ZERO_ARRAY - in this place and a few lines above. Commit 8dddea2ceda40f2365bd6b1 "lib:talloc: Use memset_s() to avoid the call gets optimized out" (Feb-2024) is a recent commit which introduces memset_s(). However, it does not seem like it makes any difference whatsoever for a testsuite, or that it actually needs to clean up the memory to begin with. We've quite an assortment of all this memory zeroing stuff. Also it is repeated in replace.h and memory.h (two sets in these files are different but has big intersection). I'd say, to fix this mess, things from replace.h should be removed in favour of memory.h, and necessary includes added, but this is for the next time. We also have lots of direct usages of memset_s() in heimdal code. Cc: Joseph Sutton <josephsutton@catalyst.net.nz> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-12talloc: Add LGPLv3 LICENSE fileAndreas Schneider1-0/+165
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15729 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2024-09-28doc: Update doc about talloc vs malloc speedAndreas Schneider3-17/+16
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net> Autobuild-User(master): Martin Schwenke <martins@samba.org> Autobuild-Date(master): Sat Sep 28 01:20:01 UTC 2024 on atb-devel-224
2024-09-28lib:talloc: Use tabs to align output in speed testAndreas Schneider1-5/+5
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
2024-09-28lib:talloc: Increase alloc size to 128 kilobytesAndreas Schneider1-16/+20
We want to avoid that the optimizer will use stack allocations. This way the test should be a bit more realistic. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
2024-09-28lib:talloc: Don't optimize the speed testAndreas Schneider1-0/+9
If the speed test gets optimized, the malloc() and free() might be replaced by stack allocations. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
2024-09-28lib:talloc: Add talloc_zero vs calloc testAndreas Schneider1-0/+39
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
2024-09-28lib:talloc: Use memset_s() to avoid the call gets optimized outAndreas Schneider2-2/+2
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
2024-09-28lib:talloc: Remove trailing spaces from testsuite.cAndreas Schneider1-31/+31
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
2024-05-31talloc:pytest: remove tests that only test Python 2Douglas Bagnall1-36/+0
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-01-29talloc: release 2.4.2talloc-2.4.2Jule Anger3-1/+83
- build with Python 3.12 (bug #15513) - documentation fixes BUG: https://bugzilla.samba.org/show_bug.cgi?id=15513 Signed-off-by: Jule Anger <janger@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
2023-12-08talloc: Fix documentationJoseph Sutton1-2/+2
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-11-20Use python.h from libreplaceAndreas Schneider3-3/+3
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15513 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-10-25talloc: Fix documentationJoseph Sutton1-1/+1
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-08-08talloc: Fix typoJoseph Sutton1-1/+1
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-07-19talloc: release 2.4.1talloc-2.4.1Stefan Metzmacher3-1/+83
* Remove remaining, but broken python2 support * Spelling fixes * Remove unneeded va_copy() Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2023-04-14lib:talloc: Fix code spellingAndreas Schneider3-5/+5
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-04-12talloc: Remove unneeded va_copy()Joseph Sutton1-3/+1
We don't use 'ap' again after this. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
2023-04-12talloc: Put comment back in appropriate placeJoseph Sutton1-1/+1
This comment originally referred, not to a va_copy() call, but to the use of &c with vsnprintf() rather than passing in NULL with a length of zero. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
2023-03-30lib:talloc: Move talloc_get_size() out of the talloc reference groupAndreas Schneider1-13/+13
This is not specific to talloc references. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-02-17talloc: remove Python 2 #if clausesDouglas Bagnall2-62/+4
Also fix an obsolete related comment. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Fri Feb 17 14:52:26 UTC 2023 on atb-devel-224
2023-02-02Python: remove pydoctorRob van der Linde2-10/+0
Removes: * waf pydoctor * waf wafdocs * make pydoctor There is no "make wafdocs" it only appears to be in wscript. The reasoning being is these are broken and appear to not have been run for some time. Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu Feb 2 21:15:54 UTC 2023 on atb-devel-224
2023-01-18talloc: version 2.4.0talloc-2.4.0Stefan Metzmacher4-2/+84
* Add talloc_asprintf_addbuf() * Support python 3.12 Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Jule Anger <janger@samba.org>
2023-01-10lib/talloc: Zero-initialise chunk pointersJoseph Sutton1-6/+6
Ensuring pointers are always initialised avoids compilation errors with FORTIFY_SOURCE=2. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org>
2022-12-14lib: Move talloc_asprintf_addbuf() to tallocVolker Lendecke5-1/+120
I wanted to use this in debug.c, but this would have meant to pollute debug's deps with a lot of stuff. Also, looking through uses of talloc_asprint_append(), very many of those don't do NULL checks properly and could benefit from the _addbuf() flavor. We can add a vasprintf variant later if the need shows up. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2022-06-08talloc: version 2.3.4talloc-2.3.4Stefan Metzmacher3-1/+82
* Fix build problems BUG: https://bugzilla.samba.org/show_bug.cgi?id=15071 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2022-03-29configure/Makefile: export PYTHONHASHSEED=1 in all 'configure/Makefile' scriptsStefan Metzmacher1-0/+7
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2022-02-24lib:replace: Reformat shell scriptsAndreas Schneider1-1/+1
shfmt -f lib/replace/ | xargs shfmt -w -p -i 0 -fn Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-11-30nsswitch: reduce dependecies to private libraries and link static/builtin if ↵Stefan Metzmacher1-0/+1
possible Over the last month I got more and more reports, that it's not possible to use a custom Samba version on systems with sssd being installed, which depends on some specific samba libraries installed in the system. One major problem is that the custom libnss_winbind.so.2 depends on the libreplace-samba4.so of the custom build and also injects an RPATH into the running process. When sssd uses any nss library call it will get this, when it then tries to load some of its plugins via dlopen(), e.g. ldd /usr/lib64/sssd/libsss_ad.so| grep samba libsamba-util.so.0 => /lib64/libsamba-util.so.0 libreplace-samba4.so => /usr/lib64/samba/libreplace-samba4.so libsamba-security-samba4.so => /usr/lib64/samba/libsamba-security-samba4.so libsamba-errors.so.1 => /lib64/libsamba-errors.so.1 libsamba-debug-samba4.so => /usr/lib64/samba/libsamba-debug-samba4.so libgenrand-samba4.so => /usr/lib64/samba/libgenrand-samba4.so libsocket-blocking-samba4.so => /usr/lib64/samba/libsocket-blocking-samba4.so libtime-basic-samba4.so => /usr/lib64/samba/libtime-basic-samba4.so libsys-rw-samba4.so => /usr/lib64/samba/libsys-rw-samba4.so libiov-buf-samba4.so => /usr/lib64/samba/libiov-buf-samba4.so When that loads dlopen() will fail as a soname libreplace-samba4.so is already loaded, but the symbol version within the other one don't match, as the contain the exact version, e.g. replace_dummy@@SAMBA_4.13.3. This is just an example and similar things can happen in all situations where we provide libraries, which are potentially injected into every process of the running system. These should only depend on libc.so and related basic system libraries in order to avoid the problem. We have the following libraries, which are in the that category: - libnss_winbind.so.2 - libnss_wins.so.2 - pam_winbind.so - winbind_krb5_locator.so - async_dns_krb5_locator.so The rules of library loading are really complex and symbol versioning is not enough to solve it, only the combination of unique soname and unique symbol version suffix seem to solve the problem, but injecting an RPATH is still a problem. In order to solve the problem I experimented with adding SAMBA_SUBSYSTEM() definitions with 'hide_symbols=True' in order to do some static linking of selected components, e.g. bld.SAMBA_SUBSYSTEM('replace-hidden', source=REPLACE_SOURCE, group='base_libraries', hide_symbols=True, deps='dl attr' + extra_libs) It's relatively simple to get to the point where the following are completely static: - libnss_winbind.so.2 - libnss_wins.so.2 - pam_winbind.so - winbind_krb5_locator.so But 'async_dns_krb5_locator.so' links in almost everything! It seems we install the krb5 plugins into our own $MODULESDIR/krb5/, so it may not be so critical, as long it's the admin who created the desired symlinks into the location the kerberos libraries search for plugins. Note the at least the locator plugins are always loaded without any configuration, every .so in a special path are loaded with dlopen(). This is done by every application using kerberos, so we load a lot of samba libraries into them. Packagers should not put async_dns_krb5_locator.so (nor a symlink) into the path that's reachable by libkrb5.so. As a longterm solution we may want to change async_dns_krb5_locator.so to use a helper process with posix_spawn() instead of doing everything within the process. Note I added hiden_symbols=True to the nss modules for Linux and FreeBSD only, because these are the only platforms I'm able to test on. We most likely should do the same on other platforms, but some with access to the platform should provide a tested patch. In order to avoid manual definitions of SAMBA_SUBSYSTEMS() with '-hidden', I added the 'provide_builtin_linking=True' option, as the logic is very similar to what we already have with the '--builtin-libraries=BUILTIN_LIBRARIES' configure option. SAMBA_PLUGIN() is used in order to use SAMBA_LIBRARY() in order to make it more strict that these plugins can't be used as normal depedency by other subsystems and libraries. While being there it was easy enough to make libwbclient.so also standalone without dependecies to other samba libraries. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2021-07-14talloc: version 2.3.3talloc-2.3.3Stefan Metzmacher3-1/+82
- python: Ensure reference counts are properly incremented - Bug 9931: change pytalloc source to LGPL Signed-off-by: Stefan Metzmacher <metze@samba.org>
2021-05-19python: Ensure reference counts are properly incrementedJoseph Sutton1-2/+2
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2021-03-16Bug 9931: change pytalloc source to LGPLDavid Disseldorp3-31/+43
pytalloc is currently GPL, while the rest of talloc is LGPL. This situation arose because pytalloc was originally developed under source4/scripting/python/, and moved into talloc proper with commit 0f043c197c473c801fc32c727194b5a2d6ae232f ("Move pytalloc to talloc directory.", October 2008). BUG: https://bugzilla.samba.org/show_bug.cgi?id=9931 Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jelmer Vernooij <jelmer@samba.org> Reviewed-by: Björn Jacke <bjacke@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Tue Mar 16 18:17:43 UTC 2021 on sn-devel-184
2020-11-10lib: talloc: Remove the ALWAYS_REALLOC code paths.talloc-2.3.2Jeremy Allison2-76/+1
This is now never set, and also never tested, and only makes the talloc code more complicated. Once this is gone we can start looking at the memlimit stuff. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org>
2020-11-10talloc: alternatively use prama init for constructors if supportedBjörn Jacke1-1/+7
Signed-off-by: Bjoern Jacke <bjacke@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2020-11-10talloc/pytalloc: fix studio compler buildBjörn Jacke1-16/+16
Solaris Studio compiler 12.4 is pedantic about prototypes in headers having the external visibility declarations too. It throws errors like: redeclaration must have the same or more restrictive linker scoping: ... Signed-off-by: Bjoern Jacke <bjacke@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2020-11-10talloc: fix studio compiler buildBjörn Jacke1-89/+97
Solaris Studio compiler 12.4 is pedantic about prototypes in headers having the external visibility declarations too. It throws errors like: redeclaration must have the same or more restrictive linker scoping: ... Signed-off-by: Bjoern Jacke <bjacke@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2020-11-09lib: talloc: More tests for realloc when used with memlimited poolsArran Cudbard-Bell1-0/+103
This requires the previous patch. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14540 Signed-off-by: Arran Cudbard-Bell <a.cudbardb@freeradius.org> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2020-11-09lib: talloc: Fix memlimit on pool realloc.Jeremy Allison4-8/+144
We only have to do the memlimit check before any real malloc or realloc. Allocations out of a memory pool have already been counted in the memory limit, so don't check in those cases. This is an application-visible change (although fixing a bug) so bump the ABI to 2.3.1 -> 2.3.2. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14540 Signed-off-by: Jeremy Allison <jra@samba.org> Signed-off-by: Arran Cudbard-Bell <a.cudbardb@freeradius.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2020-11-09lib: talloc: Add more debugging text for existing memlimit + pool testsArran Cudbard-Bell1-0/+14
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14540 Signed-off-by: Arran Cudbard-Bell <a.cudbardb@freeradius.org> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2020-11-09lib: talloc: Fix pool object accounting when doing talloc_realloc() in the ↵Jeremy Allison1-2/+5
ALWAYS_REALLOC compiled case. tc_alloc_pool() or the fallback malloc can return NULL. Wait until we know we are returning a valid pointer before decrementing pool_hdr->object_count due to reallocing out of the talloc_pool. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14540 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2020-11-09lib: talloc: Cleanup. Use consistent preprocessor logic macros.Jeremy Allison1-1/+1
Match other use of ALWAYS_REALLOC. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14540 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2020-10-16talloc: also use portable __has_attribute macro to check for "deprecated" ↵Björn Jacke1-1/+1
attribute BUG: https://bugzilla.samba.org/show_bug.cgi?id=14526 Signed-off-by: Bjoern Jacke <bjacke@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2020-06-09talloc: Mark ptr of talloc_unlink() not as a tainted scalarAndreas Schneider1-0/+2
This should address a lot of issues reported by Coverity. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2020-05-24talloc: also use portable __has_attribute macro to check for attribute supportBjörn Jacke1-1/+6
Signed-off-by: Bjoern Jacke <bjacke@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>