Commit Graph

153 Commits

Author SHA1 Message Date
Minsoo Choo
aff90c322e Fix spelling 2024-06-16 23:30:48 -04:00
Michael Tokarev
c80c04b235 spelling fixes (underun prefered relase encyption confunder)
[abartlet@samba.org: From Samba debian package at
 https://salsa.debian.org/samba-team/samba/-/blob/master/debian/patches/heimdal-spelling.patch?ref_type=heads]

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2024-06-16 23:28:43 -04:00
Joseph Sutton
551f0c32fa base: Fix code spelling
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:34:35 -05:00
Taylor R Campbell
eb0d98ba34 base/plugin.c: Constify.
As a bonus, eliminate an unnecessary rk_UNCONST.
2023-06-20 12:19:48 -05:00
Taylor R Campbell
72606cb95e libheimbase: Allow static const heim types. 2023-06-20 12:19:48 -05:00
Nicolas Williams
3e2c1c83b4 base: Translate context init error codes 2023-05-27 16:30:25 -05:00
Nicolas Williams
bc4e6591af base: Do support /dev/null as a config file 2023-05-27 16:30:25 -05:00
Taylor R Campbell
a142767598 Fix ctype.h misuse.
Excluded: libtomath and libedit files, most of which appear to be
testing or example code not involved in production, and which are
derived from an upstream that should perhaps have patches submitted
upstream instead.

fix https://github.com/heimdal/heimdal/issues/1111
2023-05-26 14:10:11 -05:00
Robert Manner
6dc36f99c0 heimbase-atomics.h: replace heim_base_atomic_barrier with syntax valid noop
in case there is no implementation available.
2023-02-06 18:17:48 -06:00
Nicolas Williams
efdd6c589d base: Fix fallback atomics 2023-01-11 12:59:12 -06:00
Nicolas Williams
08c48c10c8 base: Add atomic CAS macros/functions 2023-01-10 23:28:33 -06:00
Luke Howard
8c25c0d46a base: support for 64-bit atomic increment/decrement 2023-01-07 21:45:01 +11:00
Luke Howard
8fcf05ac2e base: wrap __machine_rw_barrier() in function for Solaris
__machine_rw_barrier() assembly expansion cannot be treated as a function call
(as it is later in the heim_base_atomic_store() macro definition)
2023-01-07 21:33:43 +11:00
Luke Howard
4e449baa29 base: add back libheimbase HEIMDAL_xxx_ATTRIBUTEs
Fix regression introduced in 62f83ad0 by adding HEIMDAL_NORETURN_ATTRIBUTE and
HEIMDAL_PRINTF_ATTRIBUTE to function definitions, so they will be included in
heimbase-protos.h.
2023-01-07 20:11:13 +11:00
Luke Howard
62f83ad024 base: don't duplicate prototypes in heimbase.h 2023-01-07 12:08:25 +11:00
Luke Howard
b3f6f4c125 base: include config.h
Solaris requires __EXTENSIONS__ to be defined before including string.h so that
the strnlen() prototype is visible
2023-01-07 11:40:48 +11:00
Luke Howard
2a594a3bd1 base: Fix CID 1518898 Resource leak
Don't leak new_node if invalid node type in heim_path_vcreate()
2023-01-04 01:36:03 -06:00
Nicolas Williams
9fc2e943ca base: Fix use-after-free in heim_path_vcreate() 2023-01-04 00:43:35 -06:00
Nicolas Williams
23a9ca27a5 base: Fix use-after-free db.c (mostly unused in prod)
We only use `db` for an2ln testing.
2023-01-04 00:43:35 -06:00
Nicolas Williams
c05294e2c5 base: Remove unused variable assignment in JSON string parsing 2023-01-04 00:43:35 -06:00
Stefan Metzmacher
dc3ac8592b heimbase-atomics: let heim_base_atomic_* use 'long' instead of 'int' on AIX
As the atomics are signed on AIX, we better try to use the largest
possible max value.

The 'int' API uses 32-bit values for both 32-bit and 64-bit binaries:

  typedef int *atomic_p;

  int fetch_and_add(atomic_p addr, int value);

The 'long' API uses 32-bit values for 32-bit binaries and 64-bit values
for 64-bit binaries:

  typedef long *atomic_l;

  long fetch_and_addlp(atomic_l addr, long value);

So we better use the 'long' API in order to avoid any potential
problems with the heim_base_atomic_integer_max magic value, where
INT[32]_MAX would be a little bit low compared to 64-bit pointer space.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
2022-12-22 22:12:52 +11:00
Stefan Metzmacher
1e5cb64569 heimbase-atomics: fix heim_base_atomic_* on AIX
The API looks like this on AIX:

  typedef int *atomic_p;

  int fetch_and_add(atomic_p addr, int value);

The strange thing is that the xlc compiler ignores missing arguments by
default. (It warns but doesn't fail to compile)
As a result the value argument was just uninitialized memory,
which means that the ref_cnt variable of struct heim_base,
gets unpredictable values during heim_retain() and heim_release(),
resulting in memory leaks.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
2022-12-22 22:12:52 +11:00
Nicolas Williams
e2e7eacb6f base: Do not include config.h twice 2022-12-15 17:44:41 -06:00
Nicolas Williams
aaff3aa5c5 Do not include config.h in heimbase.h (fix #447)
We can't include config.h in public headers, as config.h is not public.

This reverts part of commit a8f0905b71.
2022-12-08 14:06:03 -06:00
Nicolas Williams
4303e7b2a3 base: Make heim_log_ref() thread-safe (fix build) 2022-12-07 21:39:26 -06:00
Nicolas Williams
1c4902378f base: Make heim_log_ref() thread-safe
This is necessary to making multiple `krb5_context`s be able to share a
log facility.
2022-12-07 21:28:19 -06:00
Joseph Sutton
cfb32a638e Introduce macro for common plugin structure elements
Heimdal's HDB plugin interface, and hence Samba's KDC that depends upon
it, doesn't work on 32-bit builds due to structure fields being arranged
in the wrong order. This problem presents itself in the form of
segmentation faults on 32-bit systems, but goes unnoticed on 64-bit
builds thanks to extra structure padding absorbing the errant fields.

This commit reorders the HDB plugin structure fields to prevent crashes
and introduces a common macro to ensure every plugin presents a
consistent interface.

Samba BUG: https://bugzilla.samba.org/show_bug.cgi?id=15110

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2022-11-17 17:15:21 -06:00
Andrew Bartlett
c132e6ff49 lib/base: Avoid compiler warning about use-after-free on Fedora 36
While the local stack pointers could be thought of as "only"
numbers that are not invalidated by the memory they point at
being freed, any use of the pointer after the free is undefined
and so warned about (at best).

gcc version 12.2.1 20220819 (Red Hat 12.2.1-1) (GCC)

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2022-11-17 09:42:48 -05:00
Andrew Bartlett
2c8be80a25 lib/base: Correct realloc() paramters, to allocate one more byte, not 1 byte
The entry condition here is p == pend so this is really just 1 + p - p, eg just 1.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2022-11-17 09:42:48 -05:00
Volker Lendecke
f4faaeaba3 heimdal: Fix the 32-bit build on FreeBSD
Format string fixes that fail in the Samba build on a 32-bit machine

Signed-off-by: Volker Lendecke <vl@samba.org>
2022-11-16 23:46:46 -05:00
Nicolas Williams
0f919e89ca base: -Wno-string-concatenation for test_base 2022-11-01 16:10:57 -05:00
Nicolas Williams
3a5e91eca2 hcrypto: Remove MD2 with prejudice
We don't use it anywhere for anything.
2022-11-01 16:10:57 -05:00
Nicolas Williams
476d216f89 base: Fix UB 2022-11-01 16:10:57 -05:00
Nicolas Williams
1429814eda base: HEIM_JSON_F_TRY_DECODE_DATA cannot work
The idea with HEIM_JSON_F_TRY_DECODE_DATA is that on parsing of JSON
texts, if we find a base64-encoded string, decode it.  But a lot of
strings that aren't base64-encoded can be decoded anyways, leaving a
mess.

Insted we should -in a future commit- implement this only for the string
values of "heimdal-type-data-76d7fca2-d0da-4b20-a126-1a10f8a0eae6" names
in singleton objects.
2022-10-02 22:46:37 -05:00
Nicolas Williams
ed4b50720d base: Export type ID enum
Otherwise we really can't use the heimbase CF types outside lib/base!
2022-10-02 22:46:37 -05:00
Nicolas Williams
8364bdd8f3 base: Add JSON string non-ASCII escaping options
- Add HEIM_JSON_F_ESCAPE_NON_ASCII to indicate that non-ASCII must be
   escaped as \uXXXX.

 - Add HEIM_JSON_F_NO_ESCAPE_NON_ASCII to force non-escaping of BMP
   codepoints.

 - If the locale's codeset is not UTF-8 and
   HEIM_JSON_F_NO_ESCAPE_NON_ASCII is not set, then set
   HEIM_JSON_F_ESCAPE_NON_ASCII.
2022-10-02 22:46:37 -05:00
Nicolas Williams
03f06b9472 base: Prettier JSON output / options
- Add flags for indenting with 2, 4, or 8 spaces, still defaulting to
   tabs if none of those are set.

 - Don't emit a newline before emitting scalar values in dicts.
2022-10-01 00:15:37 -05:00
Nicolas Williams
c6a46f0c96 base: Implement JSON string escaping
We encode JSON in the KDC's audit logs, and soon in bx509d's /get-tgts.
Therefore, we should be reasonable in terms of what we encode.
2022-09-29 17:05:24 -05:00
Nicolas Williams
78162449b5 base: Correct UNKNOWN-0 error case
In some cases we were seeing UNKNOWN-0 when an actual error occurred.
2022-03-16 15:04:10 -05:00
Jeffrey Altman
543b94637f more dealloc functions require HEIM_CALLCONV
Change-Id: I68168a387c088b45e2572d5c982d33dfe0aa38a8
2022-01-29 00:15:59 -05:00
Luke Howard
6340602ddc base: ensure HEIM_CALLCONV used for all dealloc functions
Fixes regression introduced in 917e1604.
2022-01-29 14:29:37 +11:00
Luke Howard
917e16049a base: make heim_alloc deallocator use HEIM_CALLCONV 2022-01-28 17:24:57 -06:00
Luke Howard
ed4fe65794 base: change ret fieldname to error_code in request struct 2022-01-20 17:23:24 +11:00
Nicolas Williams
1e634df8a5 base: Context has to be optional in for path tok. exp.
We call path token expansion functions with a NULL context in CCAPI
(lib/krb5/acache.c).  We only need the context for errors.
2022-01-19 23:32:22 -06:00
Nicolas Williams
82e00128a2 base: Context has to be opt. in for error functions
This is needed so that it can be optional for path token expansion,
which has to have the context be optional for ccapi (lib/krb5/acache.c),
which in some cases calls path token expansion functions w/ a NULL
context.
2022-01-19 23:30:55 -06:00
Joseph Sutton
ef059b8831 heimdal:base: Don't perform arithmetic on a NULL pointer
Doing so is undefined behaviour.

Change-Id: Ic57baac0fc5fb06945c0dfbd5d4eb913a12fc13d
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2022-01-18 00:31:45 -05:00
Nicolas Williams
b9a915c163 base: Fix various coverity warnings 2022-01-17 16:23:36 -06:00
Nicolas Williams
ad4e055831 base: Add r->kv not-null check before using it 2022-01-17 10:58:40 -06:00
Jeffrey Altman
14cb8eef60 lib/base: heim_audit_trail init all fields of 'kvb' before use
Change-Id: I7a3cdb038eb441a394a41c52a488ed98f87dbebd
2022-01-16 15:36:02 -05:00
Jeffrey Altman
f341fa7721 prevent unintended sign extension errors
When an unsigned char is shifted << 24 bits its type will be
promoted to signed 32-bits.   If the value is then assigned to
an unsigned 64-bit value sign extension will occur.

Prevent the unwanted sign extension by explicitly casting the
value to unsigned long before shifting.

Change-Id: Iabeac0f17dc3229a2dc89abe71960a8ffbf523f8
2022-01-16 00:23:05 -05:00