Commit Graph

30165 Commits

Author SHA1 Message Date
Jeffrey Altman
1383677642 kdc: update_csr do not leak error messages
Change-Id: I478bf001ebf555dce067916e7198053ef3a0bd08
2022-01-16 23:28:13 -05:00
Jeffrey Altman
423acdfe77 kdc: check_authz free 'cprinc' on success
Change-Id: I1823a4d74c7c2823f2148f694bff1fc064d834ed
2022-01-16 23:25:06 -05:00
Jeffrey Altman
ff18c32ae4 lib/gssapi/ntlm: from_file do not leak 'f' on error
Change-Id: Ica774bc3c156c384a2cf7084259d31f445d24a7d
2022-01-16 23:10:33 -05:00
Jeffrey Altman
6e8ab0c204 lib/gssapi/spnego: _gss_negoex_accept do not leak error message
Change-Id: I464b3c5e5b96b36da2cda71b1dacc8ad971fda35
2022-01-16 23:04:54 -05:00
Jeffrey Altman
ac53ce5c99 lib/gssapi/spnego: _gss_negoex_init do not leak error message
Change-Id: I870ed0bd8de7bc6ab5b8cf7c6d3816d04de354fa
2022-01-16 23:02:38 -05:00
Jeffrey Altman
8254c01ae7 lib/gssapi/spnego: accept_sec_context free 'supported_mechs'
If no preferred mechanism was found 'supported_mechs' was leaked.

Change-Id: I2982f94d7e9569461f562987609ff7bff57b3f88
2022-01-16 22:57:15 -05:00
Jeffrey Altman
401bdd8bf3 lib/hx509: hx509_request_get_san SAN_TYPE_PKINIT return failure
if _hx509_unparse_KRB5PrincipalName() fails return the error code
to the hx509_request_get_san() caller.

Change-Id: I3ad8ceda23f00263890115f292ca7e4c8ce9317b
2022-01-16 22:43:02 -05: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
Jeffrey Altman
73e2f335c2 lib/hdb: entry2mit_string_int free unparsed name on error
if append_string() fails do not leak the unparsed name.

Change-Id: I29d909c35e0e5d7282577ce37ec283efc33edbbf
2022-01-16 22:19:39 -05:00
Jeffrey Altman
b63da31622 lib/hdb: test_namespace free hex string
Change-Id: Id69643ca70eb2c19b6c3cfc6fb99308aa29e3cc1
2022-01-16 22:14:26 -05:00
Jeffrey Altman
a73c45bef1 lib/hx509: hxtool test_crypto destroy 'vctx'
call hx509_verify_destroy_ctx to free 'vctx'

Change-Id: I4125a46760b8b988a63fb8d96d91a4a8b948b606
2022-01-16 22:11:28 -05:00
Jeffrey Altman
53e0b5448e lib/hx509: revoke_print addrof to hx509_revoke_free
1a793c04fa
("lib/hx509: revoke_print free revoke_context") forgot to pass
the address of 'revoke_ctx' to hx509_revoke_free().

Change-Id: I430a72a4dc7bce7099fc02bbe1feae625304a53a
2022-01-16 22:07:52 -05:00
Jeffrey Altman
603ee4d65d lib/hx509: _hx509_cert_to_env free 'buf'
The output buffer returned from hx509_name_to_string() must be
freed before it is overwritten by another call to
hx509_name_to_string().

Change-Id: Iaf28b14a2712cd28085ac5452819818e739d43ed
2022-01-16 21:59:49 -05:00
Jeffrey Altman
1a793c04fa lib/hx509: revoke_print free revoke_context
call hx509_revoke_free() to free the context.

Change-Id: I2f4439a848011cc0ab46f2802f5e4871baba348f
2022-01-16 21:53:06 -05:00
Jeffrey Altman
c59dd0b36c lib/hx509: hx509_request_get_san handle strpool on error
_hx509_unparse_utf8_string_name() and
_hx509_unparse_KRB5PrincipalName() can return a strpool even if
they fail.  The strpool must be passed through rk_strpoolcollect()
in order to return the contents to the caller of
hx509_request_get_san().

Change-Id: Ifda5620f4e9e00ca188aa138f692fccc12621ae8
2022-01-16 21:49:34 -05:00
Jeffrey Altman
708d9b4042 hx509_request_get_san can return an output string on failure
Tighten up all of the call sites of hx509_request_get_san()
to free the output string returned upon failure.

Use frees(&s) instead of free(s); s = NULL;.

Change-Id: I71035d7c1d2330a1a3a1b3b730cdd6ba1e6b7da3
2022-01-16 21:49:10 -05:00
Jeffrey Altman
3065730b8a lib/kadm5: find_db_spec do not leak 'info'
If a memory allocation failure occurs 'info' is leaked.

Change-Id: Ie9cfff3f7d63a1af8e053d47d5ff66411916a795
2022-01-16 21:03:00 -05:00
Jeffrey Altman
1247ca977c lib/kadm5: kadm5_ad_init_with_password_ctx free 'ctx'
kadm5_ad_destroy() frees the contents of the kadm5_ad_context
but not the kadm5_ad_context itself.

Change-Id: I70dc1fc0236166ed9725f681dfeb935f449e38cb
2022-01-16 20:09:12 -05:00
Jeffrey Altman
7c01b2af68 lib/kadm5: _kadm5_c_get_cred_cache free 'client'
If the cache principal name cannot be determined free the client
principal created from the input client name.

Change-Id: I75f96ef9f490bd9eb761a900e7a26250f1ac2b9c
2022-01-16 20:01:45 -05: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
Luke Howard
ab042dca36 gss_preauth: use memset rather than {0} to initialize cb 2022-01-17 10:05:59 +11:00
Luke Howard
0a59cbca51 kdc: use memset rather than {0} to initialize fxreq 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
65276af7f6 kdc: fast_unwrap_request use memset to init fastreq
Change-Id: I4e872126f5c1deb48d36f5bdac22da7c0df3c8a1
warning: missing braces around initializer [-Wmissing-braces]
warning: (near initialization for 'fastreq.fast_options') [-Wmissing-braces]
warning: missing initializer for field 'padata' of 'struct KrbFastReq' [-Wmissing-field-initializers]
2022-01-16 16:00:40 -05:00
Jeffrey Altman
e8ccb2b86b lib/kadm5: send_diffs() init 'ver'
warning: ‘ver’ may be used uninitialized in this function [-Wmaybe-uninitialized]

'ver' can be uninitialized if get_right() fails.

Change-Id: If6019cc3c491b8be321ff3e08f3d27292f0f1f95
2022-01-16 15:54:53 -05:00
Jeffrey Altman
c822b9bc96 gssapi/krb5: _gsskrb5_inquire_name init 'major'
If no attributes are indicated 'major' is unset.  Default to
GSS_S_UNAVAILABLE.

Change-Id: I277ebdebab0fb0322b702638c57548d1f4c4be3d
2022-01-16 15:54:47 -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
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
7ae24732c7 clang-format generated hdb, spnego and krb5 asn1.c files
Alphabetically sorted the $(spnego_files), $(gssapi_files), and $(gen_files_hdb)
lists.

Added rules to execute clang-format when available on the included files.

Change-Id: If3cde862f3237bc7cd100bc82d4fbbf568f1a354
2022-01-16 15:11:22 -05:00
Nicolas Williams
bb791ee52c hcrypto: dlclose(dso) at ENGINE finish time 2022-01-16 14:08:22 -06:00
Nicolas Williams
febdcd4cbd cf: Make clang-format style common makefile macro 2022-01-16 14:07:03 -06:00
Nicolas Williams
940aea6653 gss: clang-format ASN.1 compiler outputs 2022-01-16 14:07:03 -06:00
Nicolas Williams
2065d02aaf hdb: clang-format ASN.1 compiler outputs 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
Nicolas Williams
b889942340 bx509d: Add missing check of result of key2SPKI() 2022-01-16 13:12:22 -06:00
Jeffrey Altman
32e1604e76 lib/ipc: heim_sipc_stream_listener 'ct' lifecycle
return failure if calloc() fails

do not leak 'ct' if called with invalid 'type'

Change-Id: I384f80a51c6ec1d0980cce645c41ff3f6006fd3e
2022-01-16 00:56:16 -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