Commit Graph

30845 Commits

Author SHA1 Message Date
Joseph Sutton
ba63461cd4 wind: Support UTF-16–encoding non-BMP codepoints
View with ‘git show -b’.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-08 14:58:21 -06:00
Joseph Sutton
821fac3648 wind: Use portable integer types
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-08 14:58:21 -06:00
Joseph Sutton
db70a76074 wind: Do not perform arithmetic on a NULL pointer
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-08 14:58:21 -06:00
Joseph Sutton
ed798da1f2 wind: Fix documentation comment
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-08 14:58:21 -06:00
Nicolas Williams
d274f0e240 bx509: Test CSRs w/ BasicConstraints in extReq 2023-11-08 14:22:02 -06:00
Nicolas Williams
2ad736a579 hx509: Fix EACCES / ENOMEM confusion 2023-11-08 14:22:02 -06:00
Nicolas Williams
be0d1e68e5 hx509: Add support for CSRs w/ BasicConstraints 2023-11-08 14:22:02 -06:00
Taylor R Campbell
0f998cdbc2 ktutil: Avoid even doing arithmetic on res after realloc(res, ...).
Under C99, Sec 6.2.4, paragraph 2:

    The value of a pointer becomes indeterminate when the object it
    points to reaches the end of its lifetime.

`Indeterminate' (3.17.2) includes a trap representation, and any
reference to a trap representation is undefined behaviour.  Thus,
after realloc(res, ...) succeeds, any reference to res (or p) is
undefined behaviour.

So, instead of using `p - res` after res has been freed, use the
existing name for the value we know it has now: len.  (We could also
use alloced because p == end in this branch, and end = res + alloced,
and p = res + len.  Of course, we would have to move it up a line to
before we update alloced to have a different value.)

fix https://github.com/heimdal/heimdal/issues/1164
2023-11-07 14:20:40 -06:00
Joseph Sutton
487ba95669 wind: Don’t use invalid escape sequences
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Joseph Sutton
a18436d709 roken: Remove excess zeros in literals
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Joseph Sutton
30e3921ad1 krb5: Fix error condition
‘ret’ can only ever be equal to zero.

Found by Coverity (Samba CID 1518754).

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Joseph Sutton
b1f7a63e41 krb5: Fix error code mapping
Found by Coverity (Samba CID 1518726).

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Joseph Sutton
b0f196880c krb5: Check result of calling decode_Ticket()
Found by Coverity (Samba CID 241005).

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Joseph Sutton
0334d9e55a krb5: Check function return values
Found by Coverity (Samba CID 240644).

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Joseph Sutton
e53d594d05 krb5: Check return value of RAND_bytes()
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Joseph Sutton
62e63b2da6 krb5: Fix unused variable
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Joseph Sutton
9f05c65981 kdc: Specify client time in FAST inner KRB-ERROR
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Joseph Sutton
5de5e5f7f6 kdc: Use NULL to assign to pointers
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Joseph Sutton
f8ba91164c kdc: Don’t use uninitialized variable
The call to free_KDCDHKeyInfo(), further down, could have caused heap
corruption.

Found by Coverity (Samba CID 1544611).

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Joseph Sutton
6f73fd8206 kdc: Remove pointer cast
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Joseph Sutton
a840986dc0 hx509: Check return value of RAND_bytes()
Found by Coverity (Samba CID 1544600).

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Joseph Sutton
d1b9d2c2f9 hx509: Add missing format specifier
Found by Coverity (Samba CID 1544604).

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Joseph Sutton
7ee2ddd71a hx509: Use correct format specifier
Found by Coverity (Samba CID 1544606).

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Joseph Sutton
13f96a2c89 hx509: Don’t pass excess arguments to variadic functions
Found by Coverity (Samba CID 1544609).

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Joseph Sutton
d71035e2d1 hdb: Initialize ‘tm’ structure
‘tm’ must be initialized prior to calling strptime().

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Joseph Sutton
806bf5f571 hdb: Initialize ‘tm’ structure
‘tm’ must be initialized prior to calling strptime().

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Joseph Sutton
f7bcd8665c hdb: Remove redundant assignment
Found by Coverity (Samba CID 1544603).

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Joseph Sutton
c3e3d02b01 hcrypto: Don’t cast away const
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Nicolas Williams
c922303dd0 asn1: Do not emit the same ASN.1 C comments repeatedly 2023-09-21 23:08:34 -04:00
Nicolas Williams
cfd2ccb546 asn1: Do not emit extra typedefs that cause warnings 2023-09-21 23:08:34 -04:00
Andrew Sim
f62e2f2784 Use perl module JSON:PP, part of core, instead of JSON package
This patch removes the need for an external package.

Ported from
https://github.com/openwrt/packages/blob/master/net/samba4/patches/105-perl-json-pp.patch
402f4ba4ef (diff-208d4e0345c9d29fbec23d6f655ba794afd3052f5cb8dd73944db72ce81b847b)

Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
2023-06-24 14:54:02 -05:00
Nicolas Williams
2a38fa17b5 kdc: Add global disable_pac config param 2023-06-23 13:44:13 -05:00
Nicolas Williams
66445f4341 httpkadmind: Add auth-data-reqd attribute 2023-06-23 13:44:13 -05:00
Nicolas Williams
cfd798faaf kadmin: Add auth-data-reqd attribute 2023-06-23 13:44:13 -05:00
Nicolas Williams
f126ea6d62 kadm5: Add KRB5_KDB_AUTH_DATA_REQUIRED attribute 2023-06-23 13:44:13 -05:00
Nicolas Williams
3c4548025c hdb: Add auth-data-reqd flag 2023-06-23 13:44:13 -05:00
Nicolas Williams
27cdf81995 kdc: Honor no-auth-data-reqd on cross-real TGTs
Nowadays we use PACs instead of AD-SIGNEDPATH, so we want a PAC on every
TGT, but we don't necessarily want PACs on cross-realm TGTs.

Specifically, we don't interop well yet with AD when issuing cross-realm
TGTs with AD realms as the destination realm (see #1091).
2023-06-23 13:44:13 -05:00
Taylor R Campbell
8ac4266021 Makefile.am: Set AM_YFLAGS and AM_LFLAGS, not YFLAGS or LFLAGS.
YFLAGS and LFLAGS are reserved for the user to set, not for makefiles
to set:
https://www.gnu.org/software/automake/manual/html_node/Flag-Variables-Ordering.html

fix https://github.com/heimdal/heimdal/issues/1171
2023-06-21 20:06:58 -05:00
Taylor R Campbell
ca0e53b64f Pass -d to yacc(1) so it generates the header file.
Bison must generate this unsolicited, but BSD yacc does not.

The makefiles for lib/com_err and lib/sl already did this; this
change just adds it to lib/asn1 and lib/hx509 too.

fix https://github.com/heimdal/heimdal/issues/1100
2023-06-21 16:07:16 -05:00
Taylor R Campbell
9569ee1a3b kinit: Update SecKeychainFindGenericPassword to SecItemCopyMatching.
Tested on macOS Venture 13.4.  Not sure if this requires some
compatibility ifdefs for older macOS.

fix https://github.com/heimdal/heimdal/issues/1168
2023-06-21 13:10:15 -05:00
Taylor R Campbell
e3e271ff70 hdb/hdb-mitdb: Nix unused variable key_data in mdb_seq.
key_data is unused.  Presumably this was copypasta from DB_seq in
hdb/db.c, where it is used for the Heimdal database format in which
the value may be missing a principal but it can be recovered from the
key.  In contrast, the mit-krb5 format appears to always store the
principal in the value and _hdb_mdb_value2entry always retrieves it,
with no need for a key2principal fallback.

fix https://github.com/heimdal/heimdal/issues/1102
2023-06-20 23:18:08 -05:00
Taylor R Campbell
1d2233f907 gssmask: Use asprintf to avoid having to think about max uname.
This way there is no truncation and no build failure due to
-Werror=format-truncation as is the default in some compilers, such
as gcc7.4 with -Wall -Werror.

This is presumably not space-constrained or performance-critical; the
very next thing it does is another asprintf and frees it immediately.
And uname is not usually under any adversary's control.

fix https://github.com/heimdal/heimdal/issues/1105
2023-06-20 23:18:08 -05:00
Joseph Sutton
da9cad2047 kdc: Overwrite ‘error_code’ only if we have an actual error
‘r->error_code’ might have been set earlier, and we don’t want to
overwrite it with a successful error code.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-06-20 18:02:15 -05:00
Joseph Sutton
243207f10a kdc: Ensure that we emit a non-zero error code
If ‘r->error_code’ was zero, we would turn it into an ERR_GENERIC error
and return that to the client. Now we return the actual error code
instead.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-06-20 18:02:15 -05:00
Joseph Sutton
af0b70fcc2 kdc: Fix discarded qualifiers warning
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-06-20 18:02:15 -05:00
Joseph Sutton
043b0d02c1 kdc: Don’t abort if krb5_generate_random_keyblock() fails
There are a few reasons that this function could fail (e.g., failure to
allocate memory) besides random number generation being unavailable. No
other caller abort()s on failure like this.

Furthermore, krb5_generate_random_block(), which is called by
krb5_generate_random_keyblock(), already aborts if random generation
fails.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-06-20 18:02:15 -05:00
Joseph Sutton
43a4c01126 kdc: Fix missing space in log messages
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-06-20 18:02:15 -05:00
Joseph Sutton
4a699f2450 kdc: Remove trailing space from log message
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-06-20 18:02:15 -05:00
Joseph Sutton
cb69ce4382 kdc: Remove trailing space from log message
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-06-20 18:02:15 -05:00
Joseph Sutton
8640c7c168 krb5: Return appropriate error code 2023-06-20 18:02:15 -05:00