From bdcb3741db27d6b773ce7cdf05aab063a70ea100 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Sun, 27 May 2018 20:59:59 -0700 Subject: Update to rra-c-util 7.2 and C TAP Harness 4.3 Update to rra-c-util 7.2: * Improve configure output for krb5-config testing. * Define UINT32_MAX for systems that don't have it. * Add SPDX-License-Identifier headers to all substantial source files. * Fix new warnings from GCC 7 and Clang warnings. * Require Test::Strict 0.25 or later to run those tests. * Fix off-by-one error in return-value checks for snprintf. * Use Autoconf to probe for supported warning flags. * Fix running module-version-t -u with current versions of Perl. * Use C_TAP_SOURCE and C_TAP_BUILD instead of SOURCE and BUILD. Update to C TAP Harness 4.3: * Add support for valgrind and libtool in test lists. * Report test failures as left and right, not wanted and expected. * Fix string comparisons with NULL pointers and the string "(null)". * Add SPDX-License-Identifier headers to all substantial source files. * Avoid zero-length realloc allocations in breallocarray. * Fix new warnings from GCC 7 and Clang warnings. * Use C_TAP_SOURCE and C_TAP_BUILD instead of SOURCE and BUILD. --- tests/tap/kerberos.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'tests/tap/kerberos.c') diff --git a/tests/tap/kerberos.c b/tests/tap/kerberos.c index 6a5025a..89a36a3 100644 --- a/tests/tap/kerberos.c +++ b/tests/tap/kerberos.c @@ -12,10 +12,11 @@ * are available. * * The canonical version of this file is maintained in the rra-c-util package, - * which can be found at . + * which can be found at . * * Written by Russ Allbery - * Copyright 2006, 2007, 2009, 2010, 2011, 2012, 2013, 2014 + * Copyright 2017 Russ Allbery + * Copyright 2006-2007, 2009-2014 * The Board of Trustees of the Leland Stanford Junior University * * Permission is hereby granted, free of charge, to any person obtaining a @@ -35,6 +36,8 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. + * + * SPDX-License-Identifier: MIT */ #include @@ -361,7 +364,7 @@ kerberos_setup(enum kerberos_needs needs) path = test_file_path("config/pkinit-principal"); if (path != NULL) file = fopen(path, "r"); - if (file != NULL) { + if (path != NULL && file != NULL) { if (fgets(buffer, sizeof(buffer), file) == NULL) bail("cannot read %s", path); if (buffer[strlen(buffer) - 1] != '\n') @@ -457,17 +460,19 @@ kerberos_generate_conf(const char *realm) /* - * Report a Kerberos error and bail out. + * Report a Kerberos error and bail out. Takes a long instead of a + * krb5_error_code because it can also handle a kadm5_ret_t (which may be a + * different size). */ void -bail_krb5(krb5_context ctx, krb5_error_code code, const char *format, ...) +bail_krb5(krb5_context ctx, long code, const char *format, ...) { const char *k5_msg = NULL; char *message; va_list args; if (ctx != NULL) - k5_msg = krb5_get_error_message(ctx, code); + k5_msg = krb5_get_error_message(ctx, (krb5_error_code) code); va_start(args, format); bvasprintf(&message, format, args); va_end(args); @@ -479,17 +484,19 @@ bail_krb5(krb5_context ctx, krb5_error_code code, const char *format, ...) /* - * Report a Kerberos error as a diagnostic to stderr. + * Report a Kerberos error as a diagnostic to stderr. Takes a long instead of + * a krb5_error_code because it can also handle a kadm5_ret_t (which may be a + * different size). */ void -diag_krb5(krb5_context ctx, krb5_error_code code, const char *format, ...) +diag_krb5(krb5_context ctx, long code, const char *format, ...) { const char *k5_msg = NULL; char *message; va_list args; if (ctx != NULL) - k5_msg = krb5_get_error_message(ctx, code); + k5_msg = krb5_get_error_message(ctx, (krb5_error_code) code); va_start(args, format); bvasprintf(&message, format, args); va_end(args); @@ -524,14 +531,12 @@ kerberos_keytab_principal(krb5_context ctx, const char *path) if (status != 0) bail_krb5(ctx, status, "error reading %s", path); status = krb5_kt_next_entry(ctx, keytab, &entry, &cursor); - if (status == 0) { - status = krb5_copy_principal(ctx, entry.principal, &princ); - if (status != 0) - bail_krb5(ctx, status, "error copying principal from %s", path); - krb5_kt_free_entry(ctx, &entry); - } if (status != 0) bail("no principal found in keytab file %s", path); + status = krb5_copy_principal(ctx, entry.principal, &princ); + if (status != 0) + bail_krb5(ctx, status, "error copying principal from %s", path); + krb5_kt_free_entry(ctx, &entry); krb5_kt_end_seq_get(ctx, keytab, &cursor); krb5_kt_close(ctx, keytab); return princ; -- cgit v1.2.3