Commit Graph

5681 Commits

Author SHA1 Message Date
Nicolas Williams
a25cf6335e krb5: Fix ENOMEM path null deref in _krb5_pac_sign 2022-01-17 12:16:28 -06:00
Nicolas Williams
e15657679c krb5: Check for errors in pa_announce() 2022-01-17 12:14:23 -06:00
Nicolas Williams
014aa4569d krb5: Attempt to quiet coverity in warning user
We sometimes use this idiom where we ignore the result of some function
such as krb5_unparse_name() and then we log something and we use the
ternary operator to handle any error from that function by substituting
a string like "<unknown>" or "<out-of-memory>".  This yields some static
analyzer complaints.  Maybe casting the function's result to void will
help.
2022-01-17 12:11:49 -06:00
Nicolas Williams
2e631d3b1b krb5: FAST: Remove dead code 2022-01-17 11:53:42 -06:00
Nicolas Williams
e894ed0162 krb5: Remove dead code in enc_chal_step() 2022-01-17 11:35:12 -06:00
Nicolas Williams
5c68a02407 krb5: FAST: Fix potential double-free
Coverity incorrectly thinks this is a NULL dereference after NULL check,
but it's not.  If anything, this could be a double-free.
2022-01-17 11:22:19 -06:00
Nicolas Williams
fc42ff0212 krb5: Fix NULL-deref in send_to_kdc
Coverity thinks `handle` in lib/krb5/send_to_kdc.c:krb5_sendto_context()
at 1241 can be NULL, leading to a NULL derefence in `get_next()`.  This
is an attempt to fix this by having `get_next()` check handle for NULL.
2022-01-17 11:16:07 -06:00
Nicolas Williams
cf37c99222 krb5: get_cred: Add missing enc retval check 2022-01-17 10:53:13 -06:00
Nicolas Williams
c3643bb607 krb5: Remove KEYRING ccache dead code 2022-01-17 10:48:28 -06:00
Jeffrey Altman
f466b43975 lib/krb5: fallback_get_hosts free addrinfo if gTLD collision or error
If getaddrinfo() succeeds and returns the gTLD name collision
address the result is ignored but the allocated addrinfo was not
freed.

If allocation of the krb5_krbhst_info structure fails the addrinfo
would also be leaked.

Change-Id: I94111e081cba9548f57ad7b7e7cbea3faab7502c
2022-01-16 19:50:40 -05:00
Jeffrey Altman
9c27eaa079 lib/krb5: krb5_rc_store always fclose(f)
Change-Id: Ibc4864e97e6ada0ef09b0610669eabb1a52f896e
2022-01-16 19:37:44 -05:00
Jeffrey Altman
0a088b9b61 lib/krb5: make_pa_tgs_req do not pass ptr to in param to allocator
_krb5_mk_req_internal() accepts a (krb5_auth_context *) because
it can allocate and return a krb5_auth_context to the caller.
mkae_pa_tgs_req() should never be called with a non-NULL
krb5_auth_context but to avoid confusion, alter the signature
to accept a (krb5_auth_context *) instead of (krb5_auth_context)
so _krb5_mk_req_internal() is not called with a pointer to an
input parameter.

Change-Id: I6c2293529766eb06a9eebf41715533d8195b1f72
2022-01-16 19:31:34 -05:00
Jeffrey Altman
5838fcaa61 lib/krb5: build_logon_name use common 'out' do not leak 's2'
CHECK(ret, func(), label) jumps to the label if the function
returns non-zero.  As a result it bypasses the free(s2) call.
Use the common out label to free(s2).

Change-Id: I9a79df669e6407a82991f4a849fc16a0afaae561
2022-01-16 19:13:26 -05:00
Jeffrey Altman
6be242d46e lib/krb5: _krb5_pk_set_user_id free 'str' not 'name'
if der_print_hex_heim_integer() failed the wrong variable
would be freed.

Change-Id: I706c910423bd1f79fa7ce41af78c2f5bca24dfa5
2022-01-16 19:05:06 -05:00
Luke Howard
15f37ce09b krb5: fix hx509_free_error_string() usage
Fix build error in 7fb4698a: hx509_free_error_string() does not take a context
argument.

Change-Id: Ib24713d2425f53eb69fc9ebfc7cc1af3272b6271
2022-01-17 10:24:44 +11:00
Jeffrey Altman
800515b033 lib/krb5: akf_add_entry do not leak 'fd'
5be5faa722
("Use all DES keys, not just des-cbc-md5, verify that they all are the same.")
introduced a common out but missed a code path.

Change-Id: I27c1913c8cf87600ae34c42874bfc9d49ae1d22e
2022-01-16 18:08:50 -05:00
Luke Howard
7432589757 krb5: zeros is static, does not need explicit initializer 2022-01-17 10:05:59 +11:00
Jeffrey Altman
7fb4698aa3 lib/krb5: gen_priv_key do not leak error string
hx509_get_error_string() returns an allocated string that must
be freed with hx509_free_error_string().

Change-Id: Ib24713d2425f53eb69fc9ebfc7cc1af3272b6271
2022-01-16 17:48:13 -05:00
Jeffrey Altman
c844a1c62b lib/krb5: load_priv_key do not leak error string
hx509_get_error_string() returns an allocated string that must
be freed with hx509_free_error_string().

Change-Id: I58d160ce1b09c48b587e8adce74277f6da469ceb
2022-01-16 17:45:21 -05:00
Jeffrey Altman
c8956523a1 lib/krb5: scc_alloc do not leak 'freeme'
Introduce a common 'out' label to avoid leaking 'freeme'.

Change-Id: I8d58efc75125ee553b462372ad160394013f9a3a
2022-01-16 17:36:17 -05:00
Jeffrey Altman
5667e80742 lib/krb5: fkt_remove_entry do not leak 'emsg'
7ae2dfd853
("krb5: Fix error msg when removing keytab entries") allocated
'emsg' to prevent the leak but then forgot to use it in place
of the original krb5_get_error_message() call.

Change-Id: I0b5acdab54d75399be970837a421740f2ad7d73b
2022-01-16 17:12:34 -05:00
Jeffrey Altman
43592b2e78 lib/krb5: pa_gss_step do not leak 'from' if unparse cname fails
Change-Id: I9edcaab26b5197265dabc5feae0f83fd1c60686c
2022-01-16 17:07:05 -05:00
Jeffrey Altman
8eaecdaa59 lib/krb5: srv_find_realm do not leak 'r' if unreachable
Change-Id: I6e16676c9cb820d6a25820523608cb9854fa2ce4
2022-01-16 17:04:04 -05:00
Jeffrey Altman
085cf47738 lib/krb5: get_cred_kdc use memset to initialize 'rep'
Change-Id: Icc211f165c7aff1b0268b4c6df12eb976df2f8bd
warning: missing braces around initializer [-Wmissing-braces]
warning: (near initialization for 'rep.kdc_rep') [-Wmissing-braces]
warning: missing initializer for field 'enc_part' of 'krb5_kdc_rep' [-Wmissing-field-initializers]
2022-01-16 15:39:11 -05:00
Jeffrey Altman
041f6d5c7c lib\krb5: krb5_parse_address out of order parameters
fix the order of parameters passed to krb5_eai_to_heim_errno

Change-Id: I31271283f3f31fcb0345dd766bc511825ddd362d
2022-01-16 00:51:22 -05:00
Jeffrey Altman
363bc7d983 handle negative return values
do not pass negative values to malloc

do not pass negative values to strerror

do not pass negative values to ftruncate

do not pass negative values to fclose

Change-Id: I79ebef4e22edd14343ebeebb2ef8308785064fe8
2022-01-16 00:48:09 -05:00
Jeffrey Altman
1685c34b0d remove (krb5_enctype) cast for ETYPE_xxx
Now that ETYPE_xxx names are macros to the KRB5_ENCTYPE_xxx
symbols there is no longer a need to cast to (krb5_enctype).

Change-Id: Ib561f6e45346abac7a53eb1db0bfef60ee3bcb74
2022-01-15 22:05:50 -05:00
Jeffrey Altman
90e51a3d18 krb5.h: do not use anonymous enum for alternate E[NC]TYPE names
Use of an anonymous enum for ETYPE_xxx and ENCTYPE_xxx alternative
names results in loss of the original KRB5_ENCTYPE_xxx type.
Use CPP macros instead.

Change-Id: I84620aabd672db1d2cd0ff7a65f3ae8b34c0c684
2022-01-15 22:05:50 -05: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
754a49bd6b test_set_kvno0: Fix leak 2022-01-14 17:59:49 -06:00
Nicolas Williams
fb553dde1d krb5: Fix warnings 2022-01-14 17:10:16 -06:00
Nicolas Williams
82a8744787 krb5: Fix SQLite3 ccache bugs/warnings 2022-01-14 17:10:16 -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
318b73f002 krb5: Drop duplicated krb5.conf.5 content 2022-01-14 14:59:02 -06:00
Nicolas Williams
05e8c0ede6 Check HMAC_Init_ex() return value 2022-01-14 12:48:32 -06:00
Jeffrey Altman
3a7c2c6a7f krb5.h: define DOMAIN_X500_COMPRESS macro
db7763ca7b
("asn1: X.681/682/683 magic handling of open types")
renamed 'DOMAIN_X500_COMPRESS' to 'domain_X500_Compress'
for compliance with ASN.1 which requires values to start with
lower case and types to start with upper case.

This change adds a CPP macro DOMAIN_X500_COMPRESS for use by
third-party applications that rely upon the prior name.

Change-Id: I2eb6fec2c795c8adeeef893b00909a202257ad74
2022-01-14 12:46:08 -05:00
Nicolas Williams
0c7b06f9ca cf: Check cc support of -Werror=enum-conversion 2022-01-13 15:33:04 -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
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
Nicolas Williams
768d193e01 krb5: Fix warnings (from 54581d2d) 2022-01-06 16:24:08 -06:00
Nicolas Williams
b102c3c27f krb5: Fix canon name w/ attrs issue 2022-01-03 20:39:12 -06:00
Luke Howard
2a826d769f gss: expose PAC info buffers under urn:mspac:
Expose PAC info buffers using naming attributes prefixed with urn:mspac:,
aligned with MIT.
2022-01-03 15:59:16 +11:00
Nicolas Williams
66e256e672 krb5: Can't test KCM in test_cc 2022-01-02 22:16:06 -06:00
Nicolas Williams
1cede09a0b krb5: Add support for AD-KDC-ISSUED 2022-01-01 23:30:15 -06:00
Nicolas Williams
87f8c0d2b5 krb5: Add name attributes to krb5_principal
We now have what we need in krb5_principal to implement much of RFC6680.
Now we populate those fields so that they can be accessed by GSS-API
RFC6680 name attributes functions.

The next commit should add much of the GSS-API RFC6680 name attributes
functions and functionality.
2022-01-01 23:30:15 -06:00
Nicolas Williams
944e12e103 krb5: Add GIC optimistic FAST w/ anon 2021-12-30 18:54:54 +11:00
Luke Howard
c974f8625c krb5: PAC_EXTRA_LOGON_INFO_FLAGS_UPN_DEFAULTED fix
Only set the PAC_EXTRA_LOGON_INFO_FLAGS_UPN_DEFAULTED flag in the
UPN_DNS_INFO_EX PAC buffer, if the provided UPN matches the cname.

This is a NOOP at present, as no UPN is provided by the Heimdal KDC.
2021-12-22 16:37:24 +11:00
Luke Howard
692ed5e841 krb5: fix build regression in report_canonical_client_name
Fix build regression introduced in 5ba46072.
2021-12-22 15:01:54 +11:00