]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Correctly import "service@" GSS host-based name 1057/head
authorGreg Hudson <ghudson@mit.edu>
Mon, 30 Mar 2020 19:26:02 +0000 (15:26 -0400)
committerGreg Hudson <ghudson@mit.edu>
Tue, 31 Mar 2020 23:29:54 +0000 (19:29 -0400)
The intended way to specify only a service in a GSS host-based name is
to omit the "@" separator.  Some applications include the separator
but no hostname, and this happened to yield wildcard hostname behavior
prior to commit 996353767fe8afa7f67a3b5b465e4d70e18bad7c when
shortname qualification was added.  To restore this behavior, check in
parse_hostbased() that at least one character is present after the "@"
separator before copying the hostname.  Add a test case to t_gssapi.py.

ticket: 8892
tags: pullup
target_version: 1.18-next

src/lib/gssapi/krb5/import_name.c
src/tests/gssapi/t_gssapi.py

index da2ab1423217d289418c223e30fec73a1a3eeac8..21023dd769b289e1f2bbbf0226479ef4454db058 100644 (file)
@@ -102,8 +102,8 @@ parse_hostbased(const char *str, size_t len,
     memcpy(service, str, servicelen);
     service[servicelen] = '\0';
 
-    /* If present, copy the hostname. */
-    if (at != NULL) {
+    /* Copy the hostname if present (at least one character after '@'). */
+    if (len - servicelen > 1) {
         hostlen = len - servicelen - 1;
         host = malloc(hostlen + 1);
         if (host == NULL) {
index 54d5cf549253f046b0b780c14e7f7fe1d667d307..ecf982604a938684c3951daf44eae0d0820d3bad 100755 (executable)
@@ -47,6 +47,9 @@ realm.run(['./t_accname', 'p:service2/calvin', 'h:service2'],
           expected_msg='service2/calvin')
 realm.run(['./t_accname', 'p:service2/calvin', 'h:service1'], expected_code=1,
           expected_msg=' found in keytab but does not match server principal')
+# Regression test for #8892 (trailing @ in name).
+realm.run(['./t_accname', 'p:service1/andrew', 'h:service1@'],
+          expected_msg='service1/abraham')
 
 # Test with acceptor name containing service and host.  Use the
 # client's un-canonicalized hostname as acceptor input to mirror what