Commit Graph

1349 Commits

Author SHA1 Message Date
Nicolas Williams
e4311f3a82 asn1: Fix UB and incorrect codec for unconstrained INTEGER values of -1 2022-11-01 16:10:57 -05:00
Daria Phoebe Brashear
133f517482 rewrite fallthrough to HEIM_FALLTHROUGH to deal with new Apple SDKs
Apple clang version 14.0.0 (clang-1400.0.17.3.1) fails the build
because stds.h defines `fallthrough` as a macro which is then
expanded when base.h evaluates

  # if __has_attribute(fallthrough) && __clang_major__ >= 5

The macOS SDK defines `DISPATCH_FALLTHROUGH` as the macro instead
of `fallthrough`.

This change replaces the use of `fallthrough` in the tree with
`HEIM_FALLTHROUGH` and updates the declaration in configure logic
to define `HEIM_FALLTHROUGH` based upon existing definitions
(if any) of `fallthrough` or `DISPATCH_FALLTHROUGH`.
2022-09-16 15:58:45 -04:00
Nicolas Williams
56b60a1a40 asn1: Fix printing of decorated types 2022-03-28 16:18:10 -05:00
Nicolas Williams
db0ba731ca asn1: Allow comments and leading ws in opt files 2022-03-17 17:19:31 -05:00
Jeffrey Altman
19b337a0fb lib/asn1: new ASN1 objects require new exports
free_KERB_AD_RESTRICTION_ENTRY
encode_KERB_AD_RESTRICTION_ENTRY
decode_KERB_AD_RESTRICTION_ENTRY
length_KERB_AD_RESTRICTION_ENTRY
copy_KERB_AD_RESTRICTION_ENTRY

free_PA_KERB_KEY_LIST_REP
encode_PA_KERB_KEY_LIST_REP
decode_PA_KERB_KEY_LIST_REP
length_PA_KERB_KEY_LIST_REP
copy_PA_KERB_KEY_LIST_REP

free_PA_KERB_KEY_LIST_REQ
encode_PA_KERB_KEY_LIST_REQ
decode_PA_KERB_KEY_LIST_REQ
length_PA_KERB_KEY_LIST_REQ
copy_PA_KERB_KEY_LIST_REQ

free_PA_PAC_OPTIONS
encode_PA_PAC_OPTIONS
decode_PA_PAC_OPTIONS
length_PA_PAC_OPTIONS
copy_PA_PAC_OPTIONS

free_PA_S4U_X509_USER
encode_PA_S4U_X509_USER
decode_PA_S4U_X509_USER
length_PA_S4U_X509_USER
copy_PA_S4U_X509_USER

Change-Id: I4ccbfcec64572b41878062e50a61de3f92fdf593
2022-03-03 12:05:14 -05:00
Stefan Metzmacher
d4ac17d6d0 krb5: add new values and definitions from MS-KILE/MS-SFU
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2022-03-03 10:13:42 +11:00
Nicolas Williams
61607fa6ea asn1: Add a GitHub Markdown manual (more) 2022-02-14 21:07:47 -06:00
Nicolas Williams
dda9aa2535 asn1: Add a GitHub Markdown manual (moar) 2022-02-14 00:05:28 -06:00
Nicolas Williams
a894fc4527 asn1: Add a GitHub Markdown manual 2022-02-12 15:00:59 -06:00
Jeffrey Altman
301b7ce711 Revert "asn1: Fix Windows build"
This reverts commit ff4033eb59.
2022-01-29 00:15:59 -05:00
Nicolas Williams
4748f3a19d asn1: Revert heim_object_t support 2022-01-28 17:24:57 -06:00
Luke Howard
327ec7e75c krb5: use void * instead of heim_object for PAC decoration 2022-01-28 17:24:57 -06:00
Nicolas Williams
a835b9053d lib/asn1: generate_type_free heim_release not heim_retain
Do not leak the object when the intent is to free it.

Introduced by 40d1271094
("asn1: Expand decoration w/ C types")

Change-Id: If8cd502f61d6f9b72118630839525933911c6697
2022-01-28 13:54:16 -05:00
Jeffrey Altman
ee56cb33b2 lib/asn1: prevent wrong size argument warnings
190263bb7a
("assert non-NULL ptrs before calling mem funcs") introduced
two wrong size argument warnings.  These locations are not
errors since the allocation is simply to ensure that the
data pointer is non-NULL; length is zero.

Change-Id: I7b3b58247799a48da3653008c7b6d7fbbbf83e25
2022-01-24 00:31:27 -05:00
Jeffrey Altman
190263bb7a assert non-NULL ptrs before calling mem funcs
The definitions of memcpy(), memmove(), and memset() state that
the behaviour is undefined if any of the pointer arguments are
NULL, and some compilers are known to make use of this to
optimise away existing NULL checks in the source.

Change-Id: I489bc256e3eac7ff41d91becb0b43aba73dbb3f9
Link: https://www.imperialviolet.org/2016/06/26/nonnull.html
2022-01-24 00:07:51 -05:00
Jeffrey Altman
0a17a0b3b7 lib/asn1: der_put_length test 'size' is non-NULL
Change-Id: I1ffbf1998485fdca7cf151c24c440fb0b35e77e4
2022-01-23 21:47:58 -05:00
Jeffrey Altman
38536d7313 lib/asn1: set *size output to zero at start of der funcs
Assign zero to the output size parameter at the start so that
callers that use the value when an error occurs do not see
garbage that might be misinterpreted.

Change-Id: Iccfcf4f6944b1bf72789c83919901d9b9d6f9153
2022-01-23 00:10:14 -05:00
Nicolas Williams
d64076dfd9 asn1: Update commentary on grammar 2022-01-22 03:48:27 -06:00
Nicolas Williams
dfc26ae8c1 asn1: Fix last remaining shift/reduce conflict 2022-01-22 03:48:27 -06:00
Nicolas Williams
e1fa08a4d6 asn1: Fix 5 shift/reduce conflicts
There remains one tough shift/reduce conflict, the warning for which is
quieted with an `%expect 1` directive.

The remaining conflict has to do with whether a constraint attaches to
the inner type that some other outer type is a SET OF or SEQUENCE OF or
tagged-type of, or whether it attaches to the outer type.  The two are
really the same thing.  The latter is the reduce side, so it's not used,
but if it were we could grab the constraint in the action and attach it
to the inner type anyways.
2022-01-21 22:37:05 -06:00
Jeffrey Altman
04527412e3 Follow the Linux kernel's lead on "fallthrough"
The pseudo keyword 'fallthrough' is defined such that case statement
blocks must end with any of these keywords:
 * break;
 * fallthrough;
 * continue;
 * goto <label>;
 * return [expression];
 *
 *  gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes

The macro is defined either as

  __attribute__((__fallthrough__))

or as

  do {} while (0)  /* fallthrough */

not including the semicolon.

This change implements the Linux kernel style and updates several locations
where "/*fallthrough*/ and /* FALLTHROUGH */ were not previously replaced.

Externally imported code such as libedit, libtommath and sqlite are
restored to their unaltered state.

Change-Id: I69db8167b0d5884f55d96d72de3059a0235a1ba3
2022-01-21 10:39:47 -05:00
Joseph Sutton
1c93a6ff26 heimdal: Avoid overflow when performing bitwise shift operations
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2022-01-18 00:31:45 -05:00
Nicolas Williams
68e2135361 asn1: Fix coverity warnings 2022-01-17 16:00:07 -06:00
Nicolas Williams
a0278f7da2 asn1: Add error checking for open types 2022-01-17 16:00:07 -06:00
Nicolas Williams
9fb444983e asn1: Better handling of >63 named bits/ints
First, we enlarge Member's val field to int64_t.

Then we warn about skipping 2int, int2, and parse units glue for such
things with too-large members.

And we error out when generating the template for such things with
>UINT32_MAX members.

What about too-negative members?  That could be a thing for INTEGER /
ENUMERATED.  We'll look at that later.
2022-01-17 12:39:19 -06:00
Jeffrey Altman
424aa1cb78 lib/asn1: _asn1_print_open_type free 'indents'
'indents' was leaked on one code path.

Change-Id: Ib4a7a8dcf7aae05a79ac6738da3a87a61e85c48e
2022-01-16 22:22:48 -05:00
Nicolas Williams
febdcd4cbd cf: Make clang-format style common makefile macro 2022-01-16 14:07:03 -06:00
Nicolas Williams
fcfd380d15 asn1: Better clang-format / makefile pattern 2022-01-16 13:41:37 -06:00
Jeffrey Altman
fe76d53316 lib/asn1: pass correct size to mergesort_r
introduced by df3e08485b
("asn1: Add support for decoration w/ external types")

Change-Id: I6cd8b56766e4aabddb9c523cd3b4fe203d988afe
2022-01-15 22:45:59 -05:00
Nicolas Williams
a31db2af0d asn1: Allow CHOICEs to be decorated too
Prior to this commit only those C structs for SET and SEQUENCE types
could be decorated.  Now those for CHOICE types also can be decorated.

We could further extend this to SET OF and SEQUENCE OF types if it
proves useful.
2022-01-15 21:09:12 -06:00
Luke Howard
867457871a krb5: make krb5_pac a heim_object_t
Make krb5_pac a heim_object_t and use heim_retain() (i.e. reference count +1)
as the copy constructor for the type decoration.

Note: this assumes that PACs included in naming attributes are immutable.
2022-01-15 18:54:57 +11:00
Luke Howard
5a952ee7b5 krb5: decorate PrincipalNameAttrs with krb5_pac
Add krb5_pac to PrincipalNameAttrs to avoid needing to re-parse it each time
gss_get_name_attribute() is called.
2022-01-15 18:54:57 +11:00
Nicolas Williams
a4e6c33780 asn1: Fix double-free in asn1parse.y 2022-01-14 22:16:50 -06:00
Nicolas Williams
f076ed57cc Fix make dist 2022-01-14 20:10:19 -06:00
Nicolas Williams
c607135a03 Use fallthrough statement attribute (moar) 2022-01-14 16:53:34 -06:00
Nicolas Williams
ddc6113610 Use fallthrough statement attribute 2022-01-14 16:32:58 -06:00
Nicolas Williams
d88298649b asn1: Fix ENOMEM NULL deref 2022-01-14 12:36:34 -06:00
Nicolas Williams
f0c46e7830 asn1: Use calloc() in generated C code 2022-01-14 12:25:43 -06:00
Nicolas Williams
1fe3d293e1 asn1: Fix warnings 2022-01-14 12:25:43 -06:00
Nicolas Williams
7f8fa65c5b asn1: Fix leak in der_copy_octet_string()
This manifested as a leak via _save fields in the template backend.
2022-01-14 12:01:34 -06:00
Nicolas Williams
0c7b06f9ca cf: Check cc support of -Werror=enum-conversion 2022-01-13 15:33:04 -06:00
Nicolas Williams
04523254c1 asn1: Restore styling of generated sources 2022-01-11 17:45:27 -06:00
Nicolas Williams
ff4033eb59 asn1: Fix Windows build 2022-01-11 17:15:59 -06:00
Nicolas Williams
6ee1554f3e Ignore enum-conversion errors
This is not a very good fix, though the warnings remain.  Such errors
can in principle be a problem because in C there is no standard enum
sizing.

In this case we have two enums with the same elements and so the same
size, so it's clearly not a problem.
2022-01-11 17:15:59 -06:00
Nicolas Williams
284b29a85c asn1: Fix missing LIB_heimbase dependency 2022-01-11 10:55:19 -06:00
Nicolas Williams
40d1271094 asn1: Expand decoration w/ C types
This commits allows `heim_object_t` as a type and causes the generated
code to use the `heim_retain()` and `heim_release()` functions for
copying and releasing values of such types.

Also, now one can have more than one decoration per-type.
2022-01-11 10:21:05 -06:00
Luke Howard
ef906991fd asn1: don't include decoration header for void *
If the decorated external type is a void *, don't include the decoration
header in the ASN.1 header, only in the template implementation. This allows
the copy constructor and destructor to be implementation private.
2022-01-11 09:57:11 -06:00
Nicolas Williams
df3e08485b asn1: Add support for decoration w/ external types
This adds support for asn1_compile --decorate=... variation that causes
decoration of an ASN.1 SET/SEQUENCE type with a field of a non-ASN.1
type.

This means we can now have an ASN.1 type to represent a request that can
then have a "hidden" field -- hidden in that it is neither encoded nor
decoded.  This field will be copied and freed when the decoration is of
an ASN.1 type or of a external, C type that comes with copy constructor
and destructor functions.  Decoration with a `void *` field which is
neither copied nor freed is also supported.

We may end up using this to, for example, replace the `hdb_entry_ex`
type by decorating `HDB_entry` with a C type that points to the `HDB` in
which the entry was found or to which it should be written.
2022-01-11 09:57:11 -06:00
Luke Howard
a96f87c4ab asn1: don't clobber checked in files in clean target
Fix regression introduced in 9427796f, where checked in files matching asn1_*.c
would be clobbered by "make clean".

Change-Id: Ifc4bbe3c46dd357fdd642040ad964c7cfe1d395c
2022-01-08 17:38:46 +11:00
Nicolas Williams
c2e3c5b66e gss: Add way to set authenticator authz-data
Now we can set Authenticator authorization-data with
gss_set_name_attribute().
2022-01-08 10:38:01 +11:00