From: Russ Allbery Date: Sat, 16 May 2020 22:35:53 +0000 (-0700) Subject: Fix warnings with Clang 10 X-Git-Tag: release/3.2~20 X-Git-Url: https://git.eyrie.org/?a=commitdiff_plain;h=fca2b9ae6f27ec12debd5f6ba4af41aaf5e24b02;p=kerberos%2Fkrb5-strength.git Fix warnings with Clang 10 Fix warnings from both the compiler and the static analyzer. Reword cracklib/HISTORY to consistently use the past tense. --- diff --git a/cracklib/HISTORY b/cracklib/HISTORY index e88ca5c..09391e2 100644 --- a/cracklib/HISTORY +++ b/cracklib/HISTORY @@ -7,17 +7,15 @@ following modifications have been made: * Modified the adjacent character check to depend on the password length. * Remove checks against the user's GECOS entry. * Don't exit on failure to open the database. - * Improve the search algorithm in FindPW somewhat. + * Improved the search algorithm in FindPW somewhat. * Don't segfault on corrupt dictionaries. * Fixed the data format output by packer to properly pad the end. - * Add ANSI C prototypes for all functions and mark const variables. - * Remove unused functions. - * Various compilation warning and portability fixes. - * Use Autoconf and portable/system.h to find types of specific lengths. - * Increase MINLENGTH. - * Add a check for a duplicated dictionary word. + * Added ANSI C prototypes for all functions and mark const variables. + * Removed unused functions. + * Increased MINLENGTH. + * Added a check for a duplicated dictionary word. * Changed error for very short passwords to match current CrackLib. - * Remove last block optimization in GetPW and start fresh each time. + * Removed last block optimization in GetPW and start fresh each time. * Close the dictionary after each password lookup. * Set hidden visibility on all CrackLib symbols. * Close the wfp file handle on PWClose if it's open. @@ -25,8 +23,9 @@ following modifications have been made: * Changed the type of some variables to size_t to avoid truncation. * Forced locale in mkdict to avoid problems with non-C-locale sort. * Added a warning to packer if processing out-of-order words. - * Added cast of CRACK_TOLOWER and CRACK_TOUPPER to char. + * Used Autoconf and portable/system.h to find types of specific lengths. * Added missing break to RULE_MFIRST "(" and RULE_MLAST ")" handling. + * Various compilation warning and portability fixes. See the leading comments in each source file for a more detailed timeline and list of changes. diff --git a/cracklib/rules.c b/cracklib/rules.c index 9046ac8..0e25f3c 100644 --- a/cracklib/rules.c +++ b/cracklib/rules.c @@ -31,6 +31,7 @@ * 2020-05-16 Russ Allbery * - Change variables from int to size_t to silence warnings. * - Add missing break to RULE_MFIRST and RULE_MLAST handling. + * - Remove break after return to silence Clang warnings. */ #include @@ -362,7 +363,6 @@ MatchClass(char class, char input) default: Debug(1, "MatchClass: unknown class %c\n", class); return (0); - break; } if (isupper(class)) @@ -832,7 +832,6 @@ Mangle(const char *input, const char *control) default: Debug(1, "Mangle: unknown command %c in %s\n", *ptr, control); return ((char *) 0); - break; } } if (!area[0]) /* have we deweted de poor widdle fing away? */ diff --git a/plugin/sqlite.c b/plugin/sqlite.c index 37aea63..34a5b0c 100644 --- a/plugin/sqlite.c +++ b/plugin/sqlite.c @@ -379,7 +379,8 @@ found: code = strength_error_dict(ctx, ERROR_DICT); fail: - memset(prefix, 0, length); + if (prefix != NULL) + memset(prefix, 0, length); memset(drowssap, 0, length); free(prefix); free(drowssap); diff --git a/tests/data/passwords/make-c-data b/tests/data/passwords/make-c-data index 471a050..9753850 100755 --- a/tests/data/passwords/make-c-data +++ b/tests/data/passwords/make-c-data @@ -5,6 +5,8 @@ # The canonical representation of our password tests is in JSON, but I don't # want to require a JSON parser for the C tests to run. This script reads the # JSON input and generates a C data structure that holds all of the tests. +# +# SPDX-License-Identifier: MIT use 5.010; use autodie; @@ -31,10 +33,12 @@ Readonly my $HEADER => <<'END_HEADER'; * for the use in C test programs. To make changes, modify the original * JSON source or (more rarely) the make-c-data script and run it again. * + * Written by Russ Allbery + * Copyright 2020 Russ Allbery * Copyright 2013 * The Board of Trustees of the Leland Stanford Junior University * - * See LICENSE for licensing terms. + * SPDX-License-Identifier: MIT */ #include @@ -135,6 +139,7 @@ my $tests_ref = load_password_tests($datafile); my $name = basename($datafile); $name =~ s{ [.]json \z }{}xms; print_fh(\*STDOUT, $HEADER); +say_fh(\*STDOUT, "extern const struct password_test ${name}_tests[];"); say_fh(\*STDOUT, "const struct password_test ${name}_tests[] = {"); # Print out the test data. @@ -195,6 +200,8 @@ Russ Allbery =head1 COPYRIGHT AND LICENSE +Copyright 2020 Russ Alllbery + Copyright 2013 The Board of Trustees of the Leland Stanford Junior University diff --git a/tests/plugin/mit-t.c b/tests/plugin/mit-t.c index 9857bb9..cdfeec9 100644 --- a/tests/plugin/mit-t.c +++ b/tests/plugin/mit-t.c @@ -71,7 +71,7 @@ load_plugin(krb5_context ctx, void **handle) char *path; krb5_error_code code; krb5_pwqual_vtable vtable = NULL; - krb5_error_code (*init)(krb5_context, int, int, krb5_plugin_vtable); + pwqual_strength_initvt *init; /* Load the module. */ path = test_file_path("../plugin/.libs/strength.so"); @@ -83,7 +83,7 @@ load_plugin(krb5_context ctx, void **handle) test_file_path_free(path); /* Find the entry point function. */ - init = dlsym(*handle, "pwqual_strength_initvt"); + init = (pwqual_strength_initvt *) dlsym(*handle, "pwqual_strength_initvt"); if (init == NULL) bail("cannot get pwqual_strength_initvt symbol: %s", dlerror());