Commit Graph

2353 Commits

Author SHA1 Message Date
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
d35c9b2d67 lib/gssapi/ntlm: _gss_ntlm_inquire_cred dead code removal
do not check 'cred_handle' for GSS-C_NO_CREDENTIAL twice.

Change-Id: I3629aa49b2d20d3444c6ede46715d65b6072484f
2022-01-23 23:11:46 -05:00
Jeffrey Altman
ca4ff365f8 lib/gssapi/mech: gss_mech_switch do not leak 'm'
If there is a memory allocation failure after 'm'
is allocated, 'm' will be leaked; free it.

Change-Id: I625273634af207fac7c489df166cebde4d467cbc
2022-01-23 23:07:36 -05:00
Roland C. Dowdeswell
8dcd05ed4d _gss_ntlm_init_sec_context() mem leaks 2022-01-22 21:54:20 -05:00
Roland C. Dowdeswell
e87fca8091 _gss_ntlm_delete_sec_context() mem leaks 2022-01-22 21:54:20 -05:00
Roland C. Dowdeswell
8526b4c627 fix memory leak near NTLM type2 response 2022-01-22 21:54:20 -05: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
Nicolas Williams
681708f416 gsskrb5: Fix coverity issue 2022-01-20 13:28:57 -06:00
Nicolas Williams
8c5030bcf7 gss: test_context: Fix leak 2022-01-19 12:35:08 -06:00
Nicolas Williams
26054d835c gss: Fix leak in gss-token 2022-01-19 12:33:11 -06:00
Nicolas Williams
f26bc69ded gss: Fix name attr leak in test_context 2022-01-18 12:35:26 -06:00
Nicolas Williams
0b137e3287 gss: Workaround valgrind "lifetime not equal" issue 2022-01-18 12:35:26 -06: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
00dd104b96 gsskrb5: Fix dead code issues in deleg cred path 2022-01-17 18:10:08 -06:00
Nicolas Williams
82b8c906e9 gsskrb5: Fix incorrect allocation failure check 2022-01-17 18:00:51 -06:00
Nicolas Williams
77c048db9b gss: Check add_builtin() errors 2022-01-17 17:59:10 -06:00
Nicolas Williams
7fe5799090 gsskrb5: Fix dead code in get_transited() 2022-01-17 11:50:16 -06:00
Nicolas Williams
fe63ddc487 gsskrb5: Remove dead code in split_attr() 2022-01-17 11:01:19 -06:00
Luke Howard
dca1048e96 gss: use memset rather than {0} to initialize channel bindings 2022-01-17 22:18:44 +11:00
Luke Howard
7f2cf34b1d gss: _gss_negoex_accept make error const
krb5_get_error_message() returns a const char *, not a char *. Amends
Change-Id I464b3c5.
2022-01-17 15:46:45 +11:00
Luke Howard
ce0ba125d9 gss: _gss_negoex_init make error const
krb5_get_error_message() returns a const char *, not a char *. Amends
Change-Id I870ed0b.
2022-01-17 15:46:41 +11: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
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
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
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
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
Jeffrey Altman
7145a8e908 gssapi/mech: mech_locl.h roken.h must be included earlier
If included roken.h should be immediately following config.h.
Doing so ensures that all platform specific headers are
included in the proper order and avoids unnecessary includes
of headers managed by roken.h.

Change-Id: I27f11b42300b6ebcfbcc8d2c53915e96b6eec1d9
2022-01-15 21:24:10 -05: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
Jeffrey Altman
9f3004bfd5 gssapi/krb5: _gsskrb5_export_sec_context copy/paste error
80f3194a76
("gssapi/krb5/{export,import}_sec_context: make smaller tokens.")
stored the source principal when it should have stored the target
principal.

Change-Id: Ife6b137f9fe8f63cdb78b4212f74d502080ec2a2
2022-01-14 23:01:30 -05:00
Nicolas Williams
f076ed57cc Fix make dist 2022-01-14 20:10:19 -06:00
Nicolas Williams
55fa5bf7d2 gsskrb5: Fix warnings 2022-01-14 17:39:05 -06:00
Nicolas Williams
96b7ea671d gss: Fix warnings 2022-01-14 17:39:05 -06:00
Nicolas Williams
65caff79a3 gss-token: Fix leak 2022-01-14 17:39:05 -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
05e8c0ede6 Check HMAC_Init_ex() return value 2022-01-14 12:48:32 -06: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
472509fd46 gsskrb5: Do not leak authenticator on retry
We have a Heimdal special where when the acceptor sends back an error
token for clock skew or ticket-not-yet-valid errors then the acceptor
application will get GSS_S_CONTINUE_NEEDED from gss_accept_sec_context()
so that the initiator may retry with the same context.

But we were retaining the auth_context, which means that when the
initiator does send a new token, the acceptor leaks memory because
krb5_verify_ap_req2() doesn't clean up the auth_context on reuse.  The
end result is that we leak a lot in those cases.
2022-01-07 21:04:19 -06:00
Nicolas Williams
2d83a0b8cd gss: Make sure to indicate PAC buffers 2022-01-08 10:38:01 +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
Nicolas Williams
fe11481cc5 gss: Make krb5 name attrs table-driven
The implementation of GSS name attributes for Kerberos (or any mechanism
with more than a tiny handful) is much nicer as a table-driven
implementation.

We now have stubs for setting and deleting attributes as well, though
these currently always fail.
2022-01-08 10:38:01 +11:00
Luke Howard
27d62bb27e gss: avoid showing PAC in test_context if anon
The Heimdal KDC does not add a PAC if an anonymous ticket was issued. As such,
test_context should not expect PAC naming attributes to be present if the
--anonymous option was passed. (This is irrelevant for now as GSS_C_ANON_FLAG
is not honored by the krb5 mechanism.)
2022-01-08 10:12:07 +11:00
Luke Howard
402884a310 gss: validate attr enumeration in test_context
Ensure the "urn:mspac:client-info" name attribute is enumerated by
gss_inquire_name(), as well as being available via gss_get_name_attribute().
2022-01-08 09:38:30 +11:00
Nicolas Williams
2b9b701dc4 gss: Fix warnings (from be708ca3cf) 2022-01-06 16:21:55 -06:00
Nicolas Williams
3af6926c7d gss: Fix sign extension bug (from be708ca3cf)
When unsigned char values are shifted, they are promoted to int (unless
sizeof(int) == sizeof(char)).  This means that the change in be708ca3cf
ultimately leads to a sign extension bug.
2022-01-06 15:25:38 -06:00