]> eyrie.org Git - kerberos/krb5-strength.git/commitdiff
Update to rra-c-util 8.2 and C TAP Harness 4.7
authorRuss Allbery <eagle@eyrie.org>
Sat, 16 May 2020 20:34:17 +0000 (13:34 -0700)
committerRuss Allbery <eagle@eyrie.org>
Sat, 16 May 2020 20:38:18 +0000 (13:38 -0700)
Update to rra-c-util 8.2:

* Implement explicit_bzero with memset if it is not available.
* Reformat all C source using clang-format 10.
* Work around Test::Strict not skipping .git directories.
* Fix warnings with perltidy 20190601 and Perl::Critic 1.134.
* Improve check for obsolete strings.
* Use a more standard all-permissive license.
* Add SPDX-License-Identifier headers to all substantial source files.
* Skip more build system files when running the test suite.
* Fix warnings with Clang 10, GCC 10, and the Clang static analyzer.
* Exclude more valgrind false positives with Kerberos libraries.

Update to C TAP Harness 4.7:

* Fix warnings with GCC 10.
* Reformat all C source using clang-format 10.
* Fixed malloc error checking in bstrndup.
* Add support for valgrind testing via test list options.
* Report test failures as left and right, not wanted and seen.
* Fix is_string comparisons involving NULL pointers and "(null)".
* Add SPDX-License-Identifier headers to all substantial source files.

80 files changed:
Makefile.am
NEWS
configure.ac
cracklib/HISTORY
cracklib/packer.h
cracklib/rules.c
m4/cc-flags.m4
m4/clang.m4
m4/krb5-config.m4
m4/krb5.m4
m4/lib-depends.m4
m4/lib-helper.m4
m4/lib-pathname.m4
m4/snprintf.m4
m4/sqlite.m4
m4/tinycdb.m4
m4/vamacros.m4
plugin/cdb.c
plugin/config.c
plugin/sqlite.c
portable/asprintf.c
portable/dummy.c
portable/kadmin.h
portable/krb5-extra.c
portable/krb5-profile.c [new file with mode: 0644]
portable/krb5.h
portable/macros.h
portable/mkstemp.c
portable/reallocarray.c
portable/snprintf.c
portable/stdbool.h
portable/strndup.c
portable/system.h
tests/README
tests/TESTS
tests/data/perlcriticrc
tests/data/perltidyrc
tests/data/valgrind.supp
tests/docs/pod-spelling-t
tests/docs/pod-t
tests/perl/critic-t
tests/perl/minimum-version-t
tests/perl/strict-t
tests/portable/asprintf-t.c
tests/portable/mkstemp-t.c
tests/portable/reallocarray-t.c
tests/portable/snprintf-t.c
tests/portable/strndup-t.c
tests/runtests.c
tests/style/obsolete-strings-t [moved from tests/docs/urls-t with 81% similarity]
tests/tap/basic.c
tests/tap/basic.h
tests/tap/kerberos.c
tests/tap/kerberos.h
tests/tap/libtap.sh
tests/tap/macros.h
tests/tap/perl/Test/RRA.pm
tests/tap/perl/Test/RRA/Automake.pm
tests/tap/perl/Test/RRA/Config.pm
tests/tap/process.c
tests/tap/process.h
tests/tap/string.c
tests/tap/string.h
tests/tools/heimdal-history-t
tests/tools/heimdal-strength-t
tests/tools/wordlist-sqlite-t
tests/tools/wordlist-t
tests/util/messages-krb5-t.c
tests/util/messages-t.c
tests/util/xmalloc-t
tests/util/xmalloc.c
tools/heimdal-history
tools/heimdal-strength.c
util/macros.h
util/messages-krb5.c
util/messages-krb5.h
util/messages.c
util/messages.h
util/xmalloc.c
util/xmalloc.h

index 454879fad227535b6db6445932a30239b3dfb706..31e30a8523c8d0280ea77f89bc15b73ca9e207c3 100644 (file)
@@ -16,10 +16,10 @@ EXTRA_DIST = .clang-format .gitignore .travis.yml README.md LICENSE     \
        tests/data/perl.conf tests/data/perlcriticrc tests/data/perltidyrc  \
        tests/data/valgrind.supp tests/data/wordlist                        \
        tests/data/wordlist.cdb tests/data/wordlist.sqlite                  \
-       tests/docs/pod-spelling-t tests/docs/pod-t tests/docs/urls-t        \
-       tests/perl/critic-t tests/perl/minimum-version-t                    \
-       tests/perl/strict-t tests/tap/libtap.sh tests/tap/perl/Test/RRA.pm  \
-       tests/tap/perl/Test/RRA/Config.pm                                   \
+       tests/docs/pod-spelling-t tests/docs/pod-t tests/perl/critic-t      \
+       tests/perl/minimum-version-t tests/perl/strict-t                    \
+       tests/style/obsolete-strings-t tests/tap/libtap.sh                  \
+       tests/tap/perl/Test/RRA.pm tests/tap/perl/Test/RRA/Config.pm        \
        tests/tap/perl/Test/RRA/Automake.pm tests/tools/heimdal-history-t   \
        tests/tools/heimdal-strength-t tests/tools/wordlist-cdb-t           \
        tests/tools/wordlist-sqlite-t tests/tools/wordlist-t                \
@@ -202,7 +202,7 @@ check-local: $(check_PROGRAMS) tests/data/dictionary.pwd
 check-valgrind: $(check_PROGRAMS) tests/data/dictionary.pwd
        rm -rf $(abs_top_builddir)/tmp-valgrind
        mkdir $(abs_top_builddir)/tmp-valgrind
-       env RRA_MAINTAINER_TESTS= valgrind --leak-check=full            \
+       env valgrind --leak-check=full          \
            --show-reachable=yes --trace-children=yes                   \
            --log-file=$(abs_top_builddir)/tmp-valgrind/log.%p          \
            --suppressions=$(abs_top_srcdir)/tests/data/valgrind.supp   \
diff --git a/NEWS b/NEWS
index b72439f74899b07e90399683131c2e4ad4b29cb4..286f7c4f4c41829d6dfb289137823a6586967f3a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,29 @@ krb5-strength 3.2 (unreleased)
     --without-cracklib to configure.  This makes the code a bit simpler
     and lighter if you don't intend to ever use the CrackLib support.
 
+    Update to rra-c-util 8.2:
+
+    * Implement explicit_bzero with memset if it is not available.
+    * Reformat all C source using clang-format 10.
+    * Work around Test::Strict not skipping .git directories.
+    * Fix warnings with perltidy 20190601 and Perl::Critic 1.134.
+    * Improve check for obsolete strings.
+    * Use a more standard all-permissive license.
+    * Add SPDX-License-Identifier headers to all substantial source files.
+    * Skip more build system files when running the test suite.
+    * Fix warnings with Clang 10, GCC 10, and the Clang static analyzer.
+    * Exclude more valgrind false positives with Kerberos libraries.
+
+    Update to C TAP Harness 4.7:
+
+    * Fix warnings with GCC 10.
+    * Reformat all C source using clang-format 10.
+    * Fixed malloc error checking in bstrndup.
+    * Add support for valgrind testing via test list options.
+    * Report test failures as left and right, not wanted and seen.
+    * Fix is_string comparisons involving NULL pointers and "(null)".
+    * Add SPDX-License-Identifier headers to all substantial source files.
+
 krb5-strength 3.1 (2016-12-25)
 
     A new configuration option, cracklib_maxlen, can be set to skip
index e2e64916052002d9d25ccacb23982da0c5773ca6..eb1dc58325297795f84448cdf4d2db094cdc5262 100644 (file)
@@ -1,8 +1,8 @@
 dnl Process this file with autoconf to produce a configure script.
 dnl
 dnl Written by Russ Allbery <eagle@eyrie.org>
-dnl Copyright 2016 Russ Allbery <eagle@eyrie.org>
-dnl Copyright 2006, 2007, 2009, 2010, 2012, 2013, 2014
+dnl Copyright 2016, 2020 Russ Allbery <eagle@eyrie.org>
+dnl Copyright 2006-2007, 2009-2010, 2012-2014
 dnl     The Board of Trustees of the Leland Stanford Junior University
 dnl
 dnl See LICENSE for licensing terms.
@@ -52,6 +52,10 @@ AC_CHECK_FUNCS([krb5_free_default_realm \
 AC_CHECK_FUNCS([krb5_get_init_creds_opt_free],
     [RRA_FUNC_KRB5_GET_INIT_CREDS_OPT_FREE_ARGS])
 AC_CHECK_DECLS([krb5_kt_free_entry], [], [], [RRA_INCLUDES_KRB5])
+AC_CHECK_FUNCS([krb5_appdefault_string], [],
+    [AC_CHECK_FUNCS([krb5_get_profile])
+     AC_CHECK_HEADERS([k5profile.h profile.h])
+     AC_LIBOBJ([krb5-profile])])
 AC_LIBOBJ([krb5-extra])
 AC_CHECK_HEADERS([kadm5/kadm5-pwcheck.h kadm5/kadm5_err.h], [], [],
     [RRA_INCLUDES_KRB5])
@@ -66,7 +70,7 @@ AC_SUBST([DL_LIBS])
 
 dnl Checks for basic C functionality.
 AC_HEADER_STDBOOL
-AC_CHECK_HEADERS([sys/bittypes.h sys/select.h sys/time.h syslog.h])
+AC_CHECK_HEADERS([strings.h sys/bittypes.h sys/select.h sys/time.h syslog.h])
 AC_CHECK_DECLS([snprintf, vsnprintf])
 RRA_C_C99_VAMACROS
 RRA_C_GNU_VAMACROS
@@ -77,7 +81,7 @@ AC_TYPE_UINT32_T
 AC_CHECK_TYPES([ssize_t], [], [],
     [#include <sys/types.h>])
 RRA_FUNC_SNPRINTF
-AC_CHECK_FUNCS([setrlimit])
+AC_CHECK_FUNCS([explicit_bzero setrlimit])
 AC_REPLACE_FUNCS([asprintf mkstemp reallocarray strndup])
 
 dnl Write out the results.
index a0081cc75056b8be7eca6e723ca406400262f666..e88ca5c3ef2a8a771190a77c9f4fd2e077b7383e 100644 (file)
@@ -25,6 +25,8 @@ 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.
+ * Added missing break to RULE_MFIRST "(" and RULE_MLAST ")" handling.
 
 See the leading comments in each source file for a more detailed timeline
 and list of changes.
index b0f6703fdb875fba90777123c49a3ef39a1299e4..2f9d5508931d52a9237f9c204e731cf7bb12ec93 100644 (file)
@@ -17,6 +17,8 @@
  *   - Fix int8, int16, and int32 definitions.
  * 2013-10-01  Russ Allbery <eagle@eyrie.org>
  *   - Set hidden visibility on all symbols by default.
+ * 2020-05-16  Russ Allbery <eagle@eyrie.org>
+ *   - Cast CRACK_TOLOWER and CRACK_TOUPPER to char.
  */
 
 #include <config.h>
@@ -84,6 +86,6 @@ extern char *Lowercase(const char *);
 /* Undo default visibility change. */
 #pragma GCC visibility pop
 
-#define CRACK_TOLOWER(a)       (isupper(a)?tolower(a):(a)) 
-#define CRACK_TOUPPER(a)       (islower(a)?toupper(a):(a)) 
+#define CRACK_TOLOWER(a)       ((char)(isupper(a)?tolower(a):(a)))
+#define CRACK_TOUPPER(a)       ((char)(islower(a)?toupper(a):(a)))
 #define STRCMP(a,b)            strcmp((a),(b))
index 8f958458b9671d54f2063ca5595c0743bccb3410..eeb9e7e5517b4981ca2b762147110efd33d537a8 100644 (file)
@@ -86,8 +86,8 @@ Debug(int val, const char *fmt, ...)
 static int
 Suffix(const char *myword, const char *suffix)
 {
-    register int i;
-    register int j;
+    register size_t i;
+    register size_t j;
     i = strlen(myword);
     j = strlen(suffix);
 
@@ -104,8 +104,8 @@ Suffix(const char *myword, const char *suffix)
 char *
 Reverse(const char *str)
 {
-    register int i;
-    register int j;
+    register size_t i;
+    register size_t j;
     static char area[STRINGSIZE];
     j = i = strlen(str);
     while (*str)
@@ -173,7 +173,7 @@ Capitalise(const char *str)
 static char *
 Pluralise(const char *string)
 {
-    register int length;
+    register size_t length;
     static char area[STRINGSIZE];
     length = strlen(string);
     strcpy(area, string);
@@ -439,8 +439,9 @@ Char2Int(char character)
 char *
 Mangle(const char *input, const char *control)
 {
-    int limit, min_to_shift;
-    register int j;
+    int limit;
+    size_t min_to_shift;
+    register size_t j;
     const char *ptr;
     static char area[STRINGSIZE * 2] = "";
     char area2[STRINGSIZE * 2] = "";
@@ -786,6 +787,8 @@ Mangle(const char *input, const char *control)
                    }
                }
            }
+            break;
+
        case RULE_MLAST:
            if (!ptr[1] || (ptr[1] == RULE_CLASS && !ptr[2]))
            {
@@ -821,6 +824,7 @@ Mangle(const char *input, const char *control)
                    }
                }
            }
+            break;
 
        default:
            Debug(1, "Mangle: unknown command %c in %s\n", *ptr, control);
index 9bbdccbcf1ab631f76b920679839f2aee1f291a5..9a749f71a97869a3731ae3c443d10acebb1f4dfb 100644 (file)
@@ -14,11 +14,11 @@ dnl
 dnl The canonical version of this file is maintained in the rra-c-util
 dnl package, available at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
 dnl
-dnl Copyright 2016 Russ Allbery <eagle@eyrie.org>
+dnl Copyright 2016-2020 Russ Allbery <eagle@eyrie.org>
 dnl Copyright 2006, 2009, 2016
 dnl     by Internet Systems Consortium, Inc. ("ISC")
 dnl
-dnl Permission to use, copy, modify, and distribute this software for any
+dnl Permission to use, copy, modify, and/or distribute this software for any
 dnl purpose with or without fee is hereby granted, provided that the above
 dnl copyright notice and this permission notice appear in all copies.
 dnl
@@ -29,12 +29,14 @@ dnl SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 dnl WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 dnl ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
 dnl IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+dnl
+dnl SPDX-License-Identifier: ISC
 
 dnl Used to build the result cache name.
 AC_DEFUN([_RRA_PROG_CC_FLAG_CACHE],
-[translit([rra_cv_compiler_c_$1], [-=], [__])])
+[translit([rra_cv_compiler_c_$1], [-=+], [___])])
 
-dnl Check whether a given flag is supported by the complier.
+dnl Check whether a given flag is supported by the compiler.
 AC_DEFUN([RRA_PROG_CC_FLAG],
 [AC_REQUIRE([AC_PROG_CC])
  AC_MSG_CHECKING([if $CC supports $1])
@@ -53,20 +55,31 @@ AC_DEFUN([RRA_PROG_CC_FLAG],
 dnl Determine the full set of viable warning flags for the current compiler.
 dnl
 dnl This is based partly on personal preference and is a fairly aggressive set
-dnl of warnings.  Desirable warnings that can't be turned on due to other
+dnl of warnings.  Desirable CC warnings that can't be turned on due to other
 dnl problems:
 dnl
-dnl   -Wconversion       http://bugs.debian.org/488884 (htons warnings)
-dnl   -Wsign-conversion  Too much noise from ssize_t and flag variables
+dnl   -Wsign-conversion  Too many fiddly changes for the benefit
 dnl   -Wstack-protector  Too many false positives from small buffers
 dnl
-dnl Last checked against gcc 6.1.0 (2016-09-25).  -D_FORTIFY_SOURCE=2 enables
+dnl Last checked against gcc 9.2.1 (2019-09-01).  -D_FORTIFY_SOURCE=2 enables
 dnl warn_unused_result attribute markings on glibc functions on Linux, which
 dnl catches a few more issues.  Add -O2 because gcc won't find some warnings
 dnl without optimization turned on.
 dnl
-dnl The warnings here are listed in the same order they're listed in the
-dnl "Preprocessor Options" and "Warning Options" chapters of the GCC manual.
+dnl For Clang, we try to use -Weverything, but we have to disable some of the
+dnl warnings:
+dnl
+dnl   -Wcast-qual                     Some structs require casting away const
+dnl   -Wdisabled-macro-expansion      Triggers on libc (sigaction.sa_handler)
+dnl   -Wpadded                        Not an actual problem
+dnl   -Wreserved-id-macros            Autoconf sets several of these normally
+dnl   -Wsign-conversion               Too many fiddly changes for the benefit
+dnl   -Wtautological-pointer-compare  False positives with for loops
+dnl   -Wundef                         Conflicts with Autoconf probe results
+dnl   -Wunreachable-code              Happens with optional compilation
+dnl   -Wunreachable-code-return       Other compilers get confused
+dnl   -Wunused-macros                 Often used on suppressed branches
+dnl   -Wused-but-marked-unused        Happens a lot with conditional code
 dnl
 dnl Sets WARNINGS_CFLAGS as a substitution variable.
 AC_DEFUN([RRA_PROG_CC_WARNINGS_FLAGS],
@@ -74,21 +87,26 @@ AC_DEFUN([RRA_PROG_CC_WARNINGS_FLAGS],
  AS_IF([test x"$CLANG" = xyes],
     [WARNINGS_CFLAGS="-Werror"
      m4_foreach_w([flag],
-        [-Weverything -Wno-padded],
+        [-Weverything -Wno-cast-qual -Wno-disabled-macro-expansion -Wno-padded
+         -Wno-sign-conversion -Wno-reserved-id-macro
+         -Wno-tautological-pointer-compare -Wno-undef -Wno-unreachable-code
+         -Wno-unreachable-code-return -Wno-unused-macros
+         -Wno-used-but-marked-unused],
         [RRA_PROG_CC_FLAG(flag,
             [WARNINGS_CFLAGS="${WARNINGS_CFLAGS} flag"])])],
     [WARNINGS_CFLAGS="-g -O2 -D_FORTIFY_SOURCE=2 -Werror"
      m4_foreach_w([flag],
-        [-fstrict-overflow -fstrict-aliasing -Wcomments -Wendif-labels -Wall
-         -Wextra -Wformat=2 -Wformat-signedness -Wnull-dereference -Winit-self
-         -Wswitch-enum -Wuninitialized -Wstrict-overflow=5
-         -Wmissing-format-attribute -Wduplicated-cond -Wtrampolines
-         -Wfloat-equal -Wdeclaration-after-statement -Wshadow -Wpointer-arith
-         -Wbad-function-cast -Wcast-align -Wwrite-strings -Wdate-time
-         -Wjump-misses-init -Wfloat-conversion -Wlogical-op
+        [-fstrict-overflow -fstrict-aliasing -Wall -Wextra -Wformat=2
+         -Wformat-overflow=2 -Wformat-signedness -Wformat-truncation=2
+         -Wnull-dereference -Winit-self -Wswitch-enum -Wstrict-overflow=5
+         -Wmissing-format-attribute -Walloc-zero -Wduplicated-branches
+         -Wduplicated-cond -Wtrampolines -Wfloat-equal
+         -Wdeclaration-after-statement -Wshadow -Wpointer-arith
+         -Wbad-function-cast -Wcast-align -Wwrite-strings -Wconversion
+         -Wno-sign-conversion -Wdate-time -Wjump-misses-init -Wlogical-op
          -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes
-         -Wnormalized=nfc -Wpacked -Wredundant-decls -Wnested-externs -Winline
-         -Wvla],
+         -Wmissing-declarations -Wnormalized=nfc -Wpacked -Wredundant-decls
+         -Wrestrict -Wnested-externs -Winline -Wvla],
         [RRA_PROG_CC_FLAG(flag,
             [WARNINGS_CFLAGS="${WARNINGS_CFLAGS} flag"])])])
  AC_SUBST([WARNINGS_CFLAGS])])
index b9ceefeb3aceabd956d960f78c237ece4328b8e6..c1815a5702c2633d2ff2fe118d31cb225f2de047 100644 (file)
@@ -10,6 +10,8 @@ dnl
 dnl This file is free software; the authors give unlimited permission to copy
 dnl and/or distribute it, with or without modifications, as long as this
 dnl notice is preserved.
+dnl
+dnl SPDX-License-Identifier: FSFULLR
 
 dnl Source used by RRA_PROG_CC_CLANG.
 AC_DEFUN([_RRA_PROG_CC_CLANG_SOURCE], [[
index 738b30b826eceffcb76e139e914c5451786d722a..bbfcdc194e6c5233c1b1ad01f499f01609475742 100644 (file)
@@ -11,12 +11,15 @@ dnl The canonical version of this file is maintained in the rra-c-util
 dnl package, available at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
 dnl
 dnl Written by Russ Allbery <eagle@eyrie.org>
-dnl Copyright 2011, 2012
+dnl Copyright 2018 Russ Allbery <eagle@eyrie.org>
+dnl Copyright 2011-2012
 dnl     The Board of Trustees of the Leland Stanford Junior University
 dnl
 dnl This file is free software; the authors give unlimited permission to copy
 dnl and/or distribute it, with or without modifications, as long as this
 dnl notice is preserved.
+dnl
+dnl SPDX-License-Identifier: FSFULLR
 
 dnl Check for krb5-config in the user's path and set PATH_KRB5_CONFIG.  This
 dnl is moved into a separate macro so that it can be loaded via AC_REQUIRE,
@@ -75,12 +78,12 @@ dnl argument if that option was requested and not supported.  Old versions of
 dnl krb5-config didn't take an argument to specify the library type, but
 dnl always returned the flags for libkrb5.
 AC_DEFUN([RRA_KRB5_CONFIG],
-[AC_REQUIRE([_RRA_KRB5_CONFIG_PATH])
- rra_krb5_config_$3=
+[rra_krb5_config_$3=
  rra_krb5_config_$3[]_ok=
  AS_IF([test x"$1" != x && test -x "$1/bin/krb5-config"],
     [rra_krb5_config_$3="$1/bin/krb5-config"],
-    [rra_krb5_config_$3="$PATH_KRB5_CONFIG"])
+    [_RRA_KRB5_CONFIG_PATH
+     rra_krb5_config_$3="$PATH_KRB5_CONFIG"])
  AS_IF([test x"$rra_krb5_config_$3" != x && test -x "$rra_krb5_config_$3"],
     [AC_CACHE_CHECK([for $2 support in krb5-config], [rra_cv_lib_$3[]_config],
          [AS_IF(["$rra_krb5_config_$3" 2>&1 | grep $2 >/dev/null 2>&1],
index 236f0b09261c716e49f5fb04b0957cfcacb00bc9..617c27b6ab6bb578cfd7a8fa0d9cb33dd9ecb4aa 100644 (file)
@@ -50,12 +50,15 @@ dnl The canonical version of this file is maintained in the rra-c-util
 dnl package, available at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
 dnl
 dnl Written by Russ Allbery <eagle@eyrie.org>
-dnl Copyright 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013, 2014
+dnl Copyright 2018 Russ Allbery <eagle@eyrie.org>
+dnl Copyright 2005-2011, 2013-2014
 dnl     The Board of Trustees of the Leland Stanford Junior University
 dnl
 dnl This file is free software; the authors give unlimited permission to copy
 dnl and/or distribute it, with or without modifications, as long as this
 dnl notice is preserved.
+dnl
+dnl SPDX-License-Identifier: FSFULLR
 
 dnl Ignore Automake conditionals if not using Automake.
 m4_define_default([AM_CONDITIONAL], [:])
@@ -137,26 +140,27 @@ dnl linkage.  The single argument, if true, says to fail if Kerberos could not
 dnl be found.
 AC_DEFUN([_RRA_LIB_KRB5_REDUCED],
 [RRA_LIB_KRB5_SWITCH
- AC_CHECK_LIB([krb5], [krb5_init_context], [KRB5_LIBS="-lkrb5"],
+ AC_CHECK_LIB([krb5], [krb5_init_context],
+    [KRB5_LIBS="-lkrb5"
+     LIBS="$KRB5_LIBS $LIBS"
+     _RRA_LIB_KRB5_CHECK_HEADER_KRB5
+     AC_CHECK_FUNCS([krb5_get_error_message],
+        [AC_CHECK_FUNCS([krb5_free_error_message])],
+        [AC_CHECK_FUNCS([krb5_get_error_string], [],
+            [AC_CHECK_FUNCS([krb5_get_err_txt], [],
+                [AC_CHECK_LIB([ksvc], [krb5_svc_get_msg],
+                    [KRB5_LIBS="$KRB5_LIBS -lksvc"
+                     AC_DEFINE([HAVE_KRB5_SVC_GET_MSG], [1])
+                     AC_CHECK_HEADERS([ibm_svc/krb5_svc.h], [], [],
+                        [RRA_INCLUDES_KRB5])],
+                    [AC_CHECK_LIB([com_err], [com_err],
+                        [KRB5_LIBS="$KRB5_LIBS -lcom_err"],
+                        [AS_IF([test x"$1" = xtrue],
+                            [AC_MSG_ERROR([cannot find usable com_err library])],
+                            [KRB5_LIBS=""])])
+                     _RRA_LIB_KRB5_CHECK_HEADER_COM_ERR])])])])],
      [AS_IF([test x"$1" = xtrue],
          [AC_MSG_ERROR([cannot find usable Kerberos library])])])
- LIBS="$KRB5_LIBS $LIBS"
- _RRA_LIB_KRB5_CHECK_HEADER_KRB5
- AC_CHECK_FUNCS([krb5_get_error_message],
-     [AC_CHECK_FUNCS([krb5_free_error_message])],
-     [AC_CHECK_FUNCS([krb5_get_error_string], [],
-         [AC_CHECK_FUNCS([krb5_get_err_txt], [],
-             [AC_CHECK_LIB([ksvc], [krb5_svc_get_msg],
-                 [KRB5_LIBS="$KRB5_LIBS -lksvc"
-                  AC_DEFINE([HAVE_KRB5_SVC_GET_MSG], [1])
-                  AC_CHECK_HEADERS([ibm_svc/krb5_svc.h], [], [],
-                     [RRA_INCLUDES_KRB5])],
-                 [AC_CHECK_LIB([com_err], [com_err],
-                     [KRB5_LIBS="$KRB5_LIBS -lcom_err"],
-                     [AS_IF([test x"$1" = xtrue],
-                         [AC_MSG_ERROR([cannot find usable com_err library])],
-                         [KRB5_LIBS=""])])
-                  _RRA_LIB_KRB5_CHECK_HEADER_COM_ERR])])])])
  RRA_LIB_KRB5_RESTORE])
 
 dnl Does the appropriate library checks for Kerberos linkage when we don't
index 4b32ef55527ad799ca2c6e81afd4d3f77ae708ff..09a2cf9f0737dd38bfdd6c6ec94ace24ae7c5f95 100644 (file)
@@ -13,12 +13,14 @@ dnl The canonical version of this file is maintained in the rra-c-util
 dnl package, available at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
 dnl
 dnl Written by Russ Allbery <eagle@eyrie.org>
-dnl Copyright 2005, 2006, 2007
+dnl Copyright 2005-2007
 dnl     The Board of Trustees of the Leland Stanford Junior University
 dnl
 dnl This file is free software; the authors give unlimited permission to copy
 dnl and/or distribute it, with or without modifications, as long as this
 dnl notice is preserved.
+dnl
+dnl SPDX-License-Identifier: FSFULLR
 
 AC_DEFUN([RRA_ENABLE_REDUCED_DEPENDS],
 [rra_reduced_depends=false
index 4e0c751c44e21ec2cef2718c5a8952c3091b6acf..481122b72a38c7e0de40df026f31159b2bf38bbd 100644 (file)
@@ -12,12 +12,15 @@ dnl The canonical version of this file is maintained in the rra-c-util
 dnl package, available at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
 dnl
 dnl Written by Russ Allbery <eagle@eyrie.org>
+dnl Copyright 2018 Russ Allbery <eagle@eyrie.org>
 dnl Copyright 2011, 2013
 dnl     The Board of Trustees of the Leland Stanford Junior University
 dnl
 dnl This file is free software; the authors give unlimited permission to copy
 dnl and/or distribute it, with or without modifications, as long as this
 dnl notice is preserved.
+dnl
+dnl SPDX-License-Identifier: FSFULLR
 
 dnl Add the library flags to the default compiler flags and then remove them.
 dnl
@@ -88,6 +91,14 @@ AC_DEFUN([RRA_LIB_HELPER_VAR_INIT],
  AC_SUBST([$1][_LDFLAGS])
  AC_SUBST([$1][_LIBS])])
 
+dnl Unset all of the variables used by a library probe.  Used with the
+dnl _OPTIONAL versions of header probes when a header or library wasn't found
+dnl and therefore the library isn't usable.
+AC_DEFUN([RRA_LIB_HELPER_VAR_CLEAR],
+[$1[]_CPPFLAGS=
+ $1[]_LDFLAGS=
+ $1[]_LIBS=])
+
 dnl Handles --with options for a non-optional library.  First argument is the
 dnl base for the switch names.  Second argument is the short description.
 dnl Third argument is the variable prefix.  The variables set are used by
index 858bed5fcfd1c19af7777a64650a54ba4b869a48..46e887978e4e541c5cee1494706f0bf641aab203 100644 (file)
@@ -16,12 +16,14 @@ dnl The canonical version of this file is maintained in the rra-c-util
 dnl package, available at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
 dnl
 dnl Written by Russ Allbery <eagle@eyrie.org>
-dnl Copyright 20082009
+dnl Copyright 2008-2009
 dnl     The Board of Trustees of the Leland Stanford Junior University
 dnl
 dnl This file is free software; the authors give unlimited permission to copy
 dnl and/or distribute it, with or without modifications, as long as this
 dnl notice is preserved.
+dnl
+dnl SPDX-License-Identifier: FSFULLR
 
 dnl Probe for the alternate library name that we should attempt on this
 dnl architecture, given the size of an int, and set rra_lib_arch_name to that
index 3d9c8517e407009173f66c352faf2ef71101b4bd..e739bbfea51abb14449580cfa945fcecb483731e 100644 (file)
@@ -13,12 +13,14 @@ dnl The canonical version of this file is maintained in the rra-c-util
 dnl package, available at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
 dnl
 dnl Written by Russ Allbery <eagle@eyrie.org>
-dnl Copyright 2006, 20082009
+dnl Copyright 2006, 2008-2009
 dnl     The Board of Trustees of the Leland Stanford Junior University
 dnl
 dnl This file is free software; the authors give unlimited permission to copy
 dnl and/or distribute it, with or without modifications, as long as this
 dnl notice is preserved.
+dnl
+dnl SPDX-License-Identifier: FSFULLR
 
 dnl Source used by RRA_FUNC_SNPRINTF.
 AC_DEFUN([_RRA_FUNC_SNPRINTF_SOURCE], [[
index edc68908fc3a04722ea564d25246cd3cb8f50c78..b0a7bd5f2a02536c53376f473c5f80de1a4109f5 100644 (file)
@@ -26,6 +26,8 @@ dnl
 dnl This file is free software; the authors give unlimited permission to copy
 dnl and/or distribute it, with or without modifications, as long as this
 dnl notice is preserved.
+dnl
+dnl SPDX-License-Identifier: FSFULLR
 
 dnl Save the current CPPFLAGS, LDFLAGS, and LIBS settings and switch to
 dnl versions that include the libevent flags.  Used as a wrapper, with
index 53176706a2c873097df2a5aadb3b436335050d60..8aff1e367a3fd0d3149a53d91e7e2e7625a73a8e 100644 (file)
@@ -23,6 +23,8 @@ dnl
 dnl This file is free software; the authors give unlimited permission to copy
 dnl and/or distribute it, with or without modifications, as long as this
 dnl notice is preserved.
+dnl
+dnl SPDX-License-Identifier: FSFULLR
 
 dnl Save the current CPPFLAGS, LDFLAGS, and LIBS settings and switch to
 dnl versions that include the TinyCDB flags.  Used as a wrapper, with
index 3ed5496f211f1c53f0561e492950d166e169771c..5595b86abfa78f22c8883ed97df69a024d3da0d0 100644 (file)
@@ -17,12 +17,14 @@ dnl The canonical version of this file is maintained in the rra-c-util
 dnl package, available at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
 dnl
 dnl Written by Russ Allbery <eagle@eyrie.org>
-dnl Copyright 2006, 20082009
+dnl Copyright 2006, 2008-2009
 dnl     The Board of Trustees of the Leland Stanford Junior University
 dnl
 dnl This file is free software; the authors give unlimited permission to copy
 dnl and/or distribute it, with or without modifications, as long as this
 dnl notice is preserved.
+dnl
+dnl SPDX-License-Identifier: FSFULLR
 
 AC_DEFUN([_RRA_C_C99_VAMACROS_SOURCE], [[
 #include <stdio.h>
index d4119177ed20a6b3ce63e7659e5b42562d89d398..d7e97daa72e71adb5ad7227b2cfdf63cf4527341 100644 (file)
@@ -70,7 +70,7 @@ in_cdb_dictionary(krb5_context ctx, krb5_pwqual_moddata data,
     int status;
 
     *found = false;
-    status = cdb_find(&data->cdb, password, strlen(password));
+    status = cdb_find(&data->cdb, password, (unsigned int) strlen(password));
     if (status < 0)
         return strength_error_system(ctx, "cannot query CDB database");
     else {
index 147d3f6522b57ee4eee40178c4af1f8fc0f6f955..f5f3dcfb92d3a8428b072cdf14ac08e89db1f5b7 100644 (file)
@@ -78,7 +78,7 @@ default_realm(krb5_context ctx)
         krb5_free_default_realm(ctx, realm);
         return NULL;
     }
-    realm_data->length = strlen(realm);
+    realm_data->length = (unsigned int) strlen(realm);
     krb5_free_default_realm(ctx, realm);
     return realm_data;
 }
index cb821ab1f924374fededb40fc8c5aec81d272152..37aea63763ecdbad753b5a576af961025c7f64cb 100644 (file)
@@ -258,7 +258,8 @@ strength_check_sqlite(krb5_context ctx, krb5_pwqual_moddata data,
                       const char *password)
 {
     krb5_error_code code;
-    size_t length, prefix_length, suffix_length;
+    size_t length;
+    int prefix_length, suffix_length;
     char *prefix = NULL;
     char *drowssap = NULL;
     bool found = false;
@@ -272,13 +273,14 @@ strength_check_sqlite(krb5_context ctx, krb5_pwqual_moddata data,
      * Determine the length of the prefix and suffix into which we'll divide
      * the string.  Passwords shorter than two characters cannot be
      * meaningfully checked using this method and cause boundary condition
-     * problems.
+     * problems.  Passwords longer than INT_MAX cannot be passed to the SQLite
+     * library.
      */
     length = strlen(password);
-    if (length < 2)
+    if (length < 2 || length > INT_MAX)
         return 0;
-    prefix_length = length / 2;
-    suffix_length = length - prefix_length;
+    prefix_length = (int) length / 2;
+    suffix_length = (int) length - prefix_length;
 
     /* Obtain the reversed password, used for suffix checks. */
     drowssap = reverse_string(password);
index 10641c61ceb7864bea3e337a1f536aa3b3287a79..0451a03ed190ea84356ddc288668a866afbd8403 100644 (file)
@@ -8,14 +8,16 @@
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2006, 2015 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2008-2009, 2011, 2013
+ *     The Board of Trustees of the Leland Stanford Junior University
  *
- * The authors hereby relinquish any claim to any copyright that they may have
- * in this work, whether granted under contract or by operation of law or
- * international treaty, and hereby commit to the public, at large, that they
- * shall not, at any time in the future, seek to enforce any copyright in this
- * work against any person or entity, or prevent any person or entity from
- * copying, publishing, distributing or creating derivative works of this
- * work.
+ * Copying and distribution of this file, with or without modification, are
+ * permitted in any medium without royalty provided the copyright notice and
+ * this notice are preserved.  This file is offered as-is, without any
+ * warranty.
+ *
+ * SPDX-License-Identifier: FSFAP
  */
 
 #include <config.h>
index 953e16d569e9365be988eb08671eda2b319f6094..121a7343edd00619ecfcb6c5eacd4eb1f686a7aa 100644 (file)
@@ -9,20 +9,22 @@
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2017 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2008, 2011, 2013
+ *     The Board of Trustees of the Leland Stanford Junior University
  *
- * The authors hereby relinquish any claim to any copyright that they may have
- * in this work, whether granted under contract or by operation of law or
- * international treaty, and hereby commit to the public, at large, that they
- * shall not, at any time in the future, seek to enforce any copyright in this
- * work against any person or entity, or prevent any person or entity from
- * copying, publishing, distributing or creating derivative works of this
- * work.
+ * Copying and distribution of this file, with or without modification, are
+ * permitted in any medium without royalty provided the copyright notice and
+ * this notice are preserved.  This file is offered as-is, without any
+ * warranty.
+ *
+ * SPDX-License-Identifier: FSFAP
  */
 
 #include <portable/macros.h>
 
 /* Prototype to avoid gcc warnings and set visibility. */
-int portable_dummy(void) __attribute__((__visibility__("hidden")));
+int portable_dummy(void) __attribute__((__const__, __visibility__("hidden")));
 
 int
 portable_dummy(void)
index e3753d582597ab8ca3414c4304190c40ed4fb2d1..45527cdfbb2243b416d3caf70075744263d47371 100644 (file)
@@ -9,14 +9,16 @@
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2015 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2011, 2013
+ *     The Board of Trustees of the Leland Stanford Junior University
  *
- * The authors hereby relinquish any claim to any copyright that they may have
- * in this work, whether granted under contract or by operation of law or
- * international treaty, and hereby commit to the public, at large, that they
- * shall not, at any time in the future, seek to enforce any copyright in this
- * work against any person or entity, or prevent any person or entity from
- * copying, publishing, distributing or creating derivative works of this
- * work.
+ * Copying and distribution of this file, with or without modification, are
+ * permitted in any medium without royalty provided the copyright notice and
+ * this notice are preserved.  This file is offered as-is, without any
+ * warranty.
+ *
+ * SPDX-License-Identifier: FSFAP
  */
 
 #ifndef PORTABLE_KADMIN_H
index c36f288efee15c77b8837a98a6e080452a258b3a..3632f8b255223f556ca78b531e357ffb0947162e 100644 (file)
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2015-2016, 2018 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2010-2012, 2014
+ *     The Board of Trustees of the Leland Stanford Junior University
  *
- * The authors hereby relinquish any claim to any copyright that they may have
- * in this work, whether granted under contract or by operation of law or
- * international treaty, and hereby commit to the public, at large, that they
- * shall not, at any time in the future, seek to enforce any copyright in this
- * work against any person or entity, or prevent any person or entity from
- * copying, publishing, distributing or creating derivative works of this
- * work.
+ * Copying and distribution of this file, with or without modification, are
+ * permitted in any medium without royalty provided the copyright notice and
+ * this notice are preserved.  This file is offered as-is, without any
+ * warranty.
+ *
+ * SPDX-License-Identifier: FSFAP
  */
 
 #include <config.h>
@@ -65,7 +67,7 @@ static const char error_unknown[] = "unknown error";
 const char *
 krb5_get_error_message(krb5_context ctx UNUSED, krb5_error_code code UNUSED)
 {
-    const char *msg = NULL;
+    const char *msg;
 
 #    if defined(HAVE_KRB5_GET_ERROR_STRING)
     msg = krb5_get_error_string(ctx);
diff --git a/portable/krb5-profile.c b/portable/krb5-profile.c
new file mode 100644 (file)
index 0000000..582e7ac
--- /dev/null
@@ -0,0 +1,237 @@
+/*
+ * Kerberos compatibility functions for AIX's NAS libraries.
+ *
+ * AIX for some reason doesn't provide the krb5_appdefault_* functions, but
+ * does provide the underlying profile library functions (as a separate
+ * libk5profile with a separate k5profile.h header file).
+ *
+ * This file is therefore (apart from the includes, opening and closing
+ * comments, and the spots marked with an rra-c-util comment) a verbatim copy
+ * of src/lib/krb5/krb/appdefault.c from MIT Kerberos 1.4.4.
+ *
+ * The canonical version of this file is maintained in the rra-c-util package,
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
+ *
+ * Copyright 1985-2005 by the Massachusetts Institute of Technology.
+ * For license information, see the end of this file.
+ */
+
+#include <config.h>
+
+#include <krb5.h>
+#ifdef HAVE_K5PROFILE_H
+# include <k5profile.h>
+#endif
+#ifdef HAVE_PROFILE_H
+# include <profile.h>
+#endif
+#include <stdio.h>
+#include <string.h>
+
+ /*xxx Duplicating this is annoying; try to work on a better way.*/
+static const char *const conf_yes[] = {
+       "y", "yes", "true", "t", "1", "on",
+       0,
+};
+
+static const char *const conf_no[] = {
+       "n", "no", "false", "nil", "0", "off",
+       0,
+};
+
+static int conf_boolean(char *s)
+{
+       const char * const *p;
+       for(p=conf_yes; *p; p++) {
+               if (!strcasecmp(*p,s))
+                       return 1;
+       }
+       for(p=conf_no; *p; p++) {
+               if (!strcasecmp(*p,s))
+               return 0;
+       }
+       /* Default to "no" */
+       return 0;
+}
+
+static krb5_error_code appdefault_get(krb5_context context, const char *appname, const krb5_data *realm, const char *option, char **ret_value)
+{
+        profile_t profile;
+        const char *names[5];
+       char **nameval = NULL;
+       krb5_error_code retval;
+       const char * realmstr =  realm?realm->data:NULL;
+
+        /*
+         * rra-c-util: The magic values are internal, so a magic check for the
+         * context struct was removed here.  Call krb5_get_profile if it's
+         * available since the krb5_context struct may be opaque.
+         */
+           if (!context) 
+           return KV5M_CONTEXT;
+
+#ifdef HAVE_KRB5_GET_PROFILE
+            krb5_get_profile(context, &profile);
+#else
+           profile = context->profile;
+#endif
+           
+       /*
+        * Try number one:
+        *
+        * [appdefaults]
+        *      app = {
+        *              SOME.REALM = {
+        *                      option = <boolean>
+        *              }
+        *      }
+        */
+
+       names[0] = "appdefaults";
+       names[1] = appname;
+
+       if (realmstr) {
+               names[2] = realmstr;
+               names[3] = option;
+               names[4] = 0;
+               retval = profile_get_values(profile, names, &nameval);
+               if (retval == 0 && nameval && nameval[0]) {
+                       *ret_value = strdup(nameval[0]);
+                       goto goodbye;
+               }
+       }
+
+       /*
+        * Try number two:
+        *
+        * [appdefaults]
+        *      app = {
+        *              option = <boolean>
+        *      }
+        */
+
+       names[2] = option;
+       names[3] = 0;
+       retval = profile_get_values(profile, names, &nameval);
+       if (retval == 0 && nameval && nameval[0]) {
+               *ret_value = strdup(nameval[0]);
+               goto goodbye;
+       }
+
+       /*
+        * Try number three:
+        *
+        * [appdefaults]
+        *      realm = {
+        *              option = <boolean>
+        */
+       
+       if (realmstr) {
+               names[1] = realmstr;
+               names[2] = option;
+               names[3] = 0;
+               retval = profile_get_values(profile, names, &nameval);
+               if (retval == 0 && nameval && nameval[0]) {
+                       *ret_value = strdup(nameval[0]);
+                       goto goodbye;
+               }
+       }
+
+       /*
+        * Try number four:
+        *
+        * [appdefaults]
+        *      option = <boolean>
+        */
+
+       names[1] = option;
+       names[2] = 0;
+       retval = profile_get_values(profile, names, &nameval);
+       if (retval == 0 && nameval && nameval[0]) {
+               *ret_value = strdup(nameval[0]);
+       } else {
+               return retval;
+       }
+
+goodbye:
+       if (nameval) {
+               char **cpp;
+               for (cpp = nameval; *cpp; cpp++)
+                       free(*cpp);
+               free(nameval);
+       }
+       return 0;
+}
+
+void KRB5_CALLCONV 
+krb5_appdefault_boolean(krb5_context context, const char *appname, const krb5_data *realm, const char *option, int default_value, int *ret_value)
+{
+       char *string = NULL;
+       krb5_error_code retval;
+
+       retval = appdefault_get(context, appname, realm, option, &string);
+
+       if (! retval && string) {
+               *ret_value = conf_boolean(string);
+               free(string);
+       } else
+               *ret_value = default_value;
+}
+
+void KRB5_CALLCONV 
+krb5_appdefault_string(krb5_context context, const char *appname, const krb5_data *realm, const char *option, const char *default_value, char **ret_value)
+{
+       krb5_error_code retval;
+       char *string;
+
+       retval = appdefault_get(context, appname, realm, option, &string);
+
+       if (! retval && string) {
+               *ret_value = string;
+       } else {
+               *ret_value = strdup(default_value);
+       }
+}
+
+/*
+ * Copyright (C) 1985-2005 by the Massachusetts Institute of Technology.
+ * All rights reserved.
+ * 
+ * Export of this software from the United States of America may require
+ * a specific license from the United States Government.  It is the
+ * responsibility of any person or organization contemplating export to
+ * obtain such a license before exporting.
+ * 
+ * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
+ * distribute this software and its documentation for any purpose and
+ * without fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation, and that
+ * the name of M.I.T. not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission.  Furthermore if you modify this software you must label
+ * your software as modified software and not distribute it in such a
+ * fashion that it might be confused with the original MIT software.
+ * M.I.T. makes no representations about the suitability of this software
+ * for any purpose.  It is provided "as is" without express or implied
+ * warranty.
+ * 
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * 
+ * Individual source code files are copyright MIT, Cygnus Support,
+ * OpenVision, Oracle, Sun Soft, FundsXpress, and others.
+ * 
+ * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira,
+ * and Zephyr are trademarks of the Massachusetts Institute of Technology
+ * (MIT).  No commercial use of these trademarks may be made without
+ * prior written permission of MIT.
+ * 
+ * "Commercial use" means use of a name in a product or other for-profit
+ * manner.  It does NOT prevent a commercial firm from referring to the
+ * MIT trademarks in order to convey information (although in doing so,
+ * recognition of their trademark status should be given).
+ *
+ * There is no SPDX-License-Identifier registered for this license.
+ */
index 2b82f0e2c539b5d6976de49749dc8612648a0539..73ae433a0e7460e2591cb3b6990c7f0c12796b58 100644 (file)
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2015, 2017, 2020 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2010-2014
+ *     The Board of Trustees of the Leland Stanford Junior University
  *
- * The authors hereby relinquish any claim to any copyright that they may have
- * in this work, whether granted under contract or by operation of law or
- * international treaty, and hereby commit to the public, at large, that they
- * shall not, at any time in the future, seek to enforce any copyright in this
- * work against any person or entity, or prevent any person or entity from
- * copying, publishing, distributing or creating derivative works of this
- * work.
+ * Copying and distribution of this file, with or without modification, are
+ * permitted in any medium without royalty provided the copyright notice and
+ * this notice are preserved.  This file is offered as-is, without any
+ * warranty.
+ *
+ * SPDX-License-Identifier: FSFAP
  */
 
 #ifndef PORTABLE_KRB5_H
@@ -56,6 +58,18 @@ BEGIN_DECLS
 /* Default to a hidden visibility for all portability functions. */
 #pragma GCC visibility push(hidden)
 
+/*
+ * AIX included Kerberos includes the profile library but not the
+ * krb5_appdefault functions, so we provide replacements that we have to
+ * prototype.
+ */
+#ifndef HAVE_KRB5_APPDEFAULT_STRING
+void krb5_appdefault_boolean(krb5_context, const char *, const krb5_data *,
+                             const char *, int, int *);
+void krb5_appdefault_string(krb5_context, const char *, const krb5_data *,
+                            const char *, const char *, char **);
+#endif
+
 /*
  * MIT-specific.  The Heimdal documentation says to use free(), but that
  * doesn't actually make sense since the memory is allocated inside the
index 487ab5bf7413eed540c68d6bd94d46a8b292cc82..5d77fb75af7bd8465308dc4cac47d4f53a9ab08f 100644 (file)
@@ -5,14 +5,16 @@
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2015 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2008, 2011-2012
+ *     The Board of Trustees of the Leland Stanford Junior University
  *
- * The authors hereby relinquish any claim to any copyright that they may have
- * in this work, whether granted under contract or by operation of law or
- * international treaty, and hereby commit to the public, at large, that they
- * shall not, at any time in the future, seek to enforce any copyright in this
- * work against any person or entity, or prevent any person or entity from
- * copying, publishing, distributing or creating derivative works of this
- * work.
+ * Copying and distribution of this file, with or without modification, are
+ * permitted in any medium without royalty provided the copyright notice and
+ * this notice are preserved.  This file is offered as-is, without any
+ * warranty.
+ *
+ * SPDX-License-Identifier: FSFAP
  */
 
 #ifndef PORTABLE_MACROS_H
index 71bddad2f0206a76899e7b7d4c736f69684f4966..ebaefc1b5ee6ebd91732b364124654edde962251 100644 (file)
@@ -8,14 +8,15 @@
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2009, 2011, 2014
+ *     The Board of Trustees of the Leland Stanford Junior University
  *
- * The authors hereby relinquish any claim to any copyright that they may have
- * in this work, whether granted under contract or by operation of law or
- * international treaty, and hereby commit to the public, at large, that they
- * shall not, at any time in the future, seek to enforce any copyright in this
- * work against any person or entity, or prevent any person or entity from
- * copying, publishing, distributing or creating derivative works of this
- * work.
+ * Copying and distribution of this file, with or without modification, are
+ * permitted in any medium without royalty provided the copyright notice and
+ * this notice are preserved.  This file is offered as-is, without any
+ * warranty.
+ *
+ * SPDX-License-Identifier: FSFAP
  */
 
 #include <config.h>
index a8be45f02ab765fa36c06cd48c0a5036741d892f..635041ebe22beb8e3ce3842670ead1e3c2684812 100644 (file)
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2017 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2014
+ *     The Board of Trustees of the Leland Stanford Junior University
  *
- * The authors hereby relinquish any claim to any copyright that they may have
- * in this work, whether granted under contract or by operation of law or
- * international treaty, and hereby commit to the public, at large, that they
- * shall not, at any time in the future, seek to enforce any copyright in this
- * work against any person or entity, or prevent any person or entity from
- * copying, publishing, distributing or creating derivative works of this
- * work.
+ * Copying and distribution of this file, with or without modification, are
+ * permitted in any medium without royalty provided the copyright notice and
+ * this notice are preserved.  This file is offered as-is, without any
+ * warranty.
+ *
+ * SPDX-License-Identifier: FSFAP
  */
 
 #include <config.h>
@@ -52,5 +54,11 @@ reallocarray(void *ptr, size_t nmemb, size_t size)
             errno = ENOMEM;
             return NULL;
         }
+
+    /* Avoid a zero-size allocation. */
+    if (nmemb == 0 || size == 0) {
+        nmemb = 1;
+        size = 1;
+    }
     return realloc(ptr, nmemb * size);
 }
index 3aaf3fd224714f78d820ac337fc2482467db4c10..a22e4e47d24757d9443d850a4057699db588c720 100644 (file)
 # define vsnprintf test_vsnprintf
 #endif
 
+/*
+ * __attribute__ is available in gcc 2.5 and later, but only with gcc 2.7
+ * could you use the __format__ form of the attributes, which is what we use
+ * (to avoid confusion with other macros).
+ */
+#ifndef __attribute__
+#    if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
+#        define __attribute__(spec) /* empty */
+#    endif
+#endif
+
+/*
+ * Older Clang doesn't support __attribute__((fallthrough)) properly and
+ * complains about the empty statement that it is decorating.  Suppress that
+ * warning.  Also suppress warnings about unknown attributes to handle older
+ * Clang versions.
+ */
+#if !defined(__attribute__) && (defined(__llvm__) || defined(__clang__))
+#    pragma GCC diagnostic ignored "-Wattributes"
+#    pragma GCC diagnostic ignored "-Wmissing-declarations"
+#endif
+
+/* Specific to rra-c-util, but only when debugging is enabled. */
+#ifdef DEBUG_SNPRINTF
+# include <util/messages.h>
+#endif
+
 /*
  * Copyright Patrick Powell 1995
  * This code is based on code written by Patrick Powell (papowell@astart.com)
  * It may be used for any purpose as long as this notice remains intact
  * on all source code distributions
+ *
+ * There is no SPDX-License-Identifier registered for this license.
  */
 
 /**************************************************************
@@ -57,7 +86,7 @@
  *    probably requires libm on most operating systems.  Don't yet
  *    support the exponent (e,E) and sigfig (g,G).  Also, fmtint()
  *    was pretty badly broken, it just wasn't being exercised in ways
- *    which showed it, so that's been fixed.  Also, formated the code
+ *    which showed it, so that's been fixed.  Also, formatted the code
  *    to mutt conventions, and removed dead code left over from the
  *    original.  Also, there is now a builtin-test, just compile with:
  *           gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm
  *    fixed return value to comply with C99
  *    fixed handling of snprintf(NULL, ...)
  *    added explicit casts for double to long long int conversion
+ *    fixed various warnings with GCC 7
+ *    fixed various warnings with Clang
  *
- *  Hrvoje Niksic <hniksic@arsdigita.com> 2000-11-04
+ *  Hrvoje Niksic <hniksic@xemacs.org> 2000-11-04
+ *    include <config.h> instead of "config.h".
+ *    moved TEST_SNPRINTF stuff out of HAVE_SNPRINTF ifdef.
  *    include <stdio.h> for NULL.
- *    added support for long long.
+ *    added support and test cases for long long.
  *    don't declare argument types to (v)snprintf if stdarg is not used.
+ *    use int instead of short int as 2nd arg to va_arg.
+ *
+ *  alexk (INN) 2002-08-21
+ *    use LLONG in fmtfp to handle more characters during floating
+ *    point conversion.
+ *
+ *  herb (Samba) 2002-12-19
+ *    actually print args for %g and %e
  *
  *  Hrvoje Niksic <hniksic@xemacs.org> 2005-04-15
  *    use the PARAMS macro to handle prototypes.
 /* varargs declarations: */
 
 #include <stdarg.h>
-#define HAVE_STDARGS    /* let's hope that works everywhere (mj) */
-#define VA_LOCAL_DECL   va_list ap
-#define VA_START(f)     va_start(ap, f)
-#define VA_SHIFT(v,t)  ;   /* no-op for ANSI */
-#define VA_END          va_end(ap)
 
 /* Assume all compilers support long double, per Autoconf documentation. */
 #define LDOUBLE long double
@@ -352,6 +388,8 @@ static int dopr (char *buffer, size_t maxlen, const char *format, va_list args)
        break;
       case 'X':
        flags |= DP_F_UP;
+        __attribute__((fallthrough));
+        /* fall through */
       case 'x':
        flags |= DP_F_UNSIGNED;
        if (cflags == DP_C_SHORT)
@@ -368,33 +406,38 @@ static int dopr (char *buffer, size_t maxlen, const char *format, va_list args)
        if (cflags == DP_C_LDOUBLE)
          fvalue = va_arg (args, LDOUBLE);
        else
-         fvalue = va_arg (args, double);
+         fvalue = (LDOUBLE) va_arg (args, double);
        total += fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags);
        break;
       case 'E':
        flags |= DP_F_UP;
+        __attribute__((fallthrough));
+        /* fall through */
       case 'e':
        if (cflags == DP_C_LDOUBLE)
          fvalue = va_arg (args, LDOUBLE);
        else
-         fvalue = va_arg (args, double);
+         fvalue = (LDOUBLE) va_arg (args, double);
         total += fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags);
        break;
       case 'G':
        flags |= DP_F_UP;
+        __attribute__((fallthrough));
+        /* fall through */
       case 'g':
         flags |= DP_F_FP_G;
        if (cflags == DP_C_LDOUBLE)
          fvalue = va_arg (args, LDOUBLE);
        else
-         fvalue = va_arg (args, double);
+         fvalue = (LDOUBLE) va_arg (args, double);
        if (max == 0)
          /* C99 says: if precision [for %g] is zero, it is taken as one */
          max = 1;
        total += fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags);
        break;
       case 'c':
-       total += dopr_outch (buffer, &currlen, maxlen, va_arg (args, int));
+       total += dopr_outch (buffer, &currlen, maxlen,
+                            (char) va_arg (args, int));
        break;
       case 's':
        strvalue = va_arg (args, char *);
@@ -410,7 +453,7 @@ static int dopr (char *buffer, size_t maxlen, const char *format, va_list args)
        {
          short int *num;
          num = va_arg (args, short int *);
-         *num = currlen;
+         *num = (short) currlen;
         } 
        else if (cflags == DP_C_LONG) 
        {
@@ -428,7 +471,7 @@ static int dopr (char *buffer, size_t maxlen, const char *format, va_list args)
        {
          int *num;
          num = va_arg (args, int *);
-         *num = currlen;
+         *num = (int) currlen;
         }
        break;
       case '%':
@@ -477,7 +520,7 @@ static int fmtstr (char *buffer, size_t *currlen, size_t maxlen,
   }
 
   if (max < 0)
-    strln = strlen (value);
+    strln = (int) strlen (value);
   else
     /* When precision is specified, don't read VALUE past precision. */
     /*strln = strnlen (value, max);*/
@@ -511,7 +554,7 @@ static int fmtstr (char *buffer, size_t *currlen, size_t maxlen,
 static int fmtint (char *buffer, size_t *currlen, size_t maxlen,
                   LLONG value, int base, int min, int max, int flags)
 {
-  int signvalue = 0;
+  char signvalue = 0;
   unsigned LLONG uvalue;
   char convert[24];
   unsigned int place = 0;
@@ -565,8 +608,8 @@ static int fmtint (char *buffer, size_t *currlen, size_t maxlen,
     spadlen = -spadlen; /* Left Justifty */
 
 #ifdef DEBUG_SNPRINTF
-  dprint (1, (debugfile, "zpad: %d, spad: %d, min: %d, max: %d, place: %d\n",
-      zpadlen, spadlen, min, max, place));
+  debug ("zpad: %d, spad: %d, min: %d, max: %d, place: %u\n",
+         zpadlen, spadlen, min, max, place);
 #endif
 
   /* Spaces */
@@ -613,7 +656,7 @@ static LDOUBLE abs_val (LDOUBLE value)
   return result;
 }
 
-static LLONG pow10_int (int exp)
+static LLONG pow10_int (unsigned int exp)
 {
   LDOUBLE result = 1;
 
@@ -632,23 +675,31 @@ static LLONG round_int (LDOUBLE value)
 
   intpart = (LLONG) value;
   value = value - intpart;
-  if (value >= 0.5)
+  if (value >= (LDOUBLE) 0.5)
     intpart++;
 
   return intpart;
 }
 
+/*
+ * GCC 7.1 issues this warning at the point of the function definition header
+ * (not in any actual code), and I can't figure out what's triggering it since
+ * the comparison form doesn't appear anywhere in this code.  Since this is
+ * rarely-used portability code, suppress the warning.
+ */
+#pragma GCC diagnostic ignored "-Wstrict-overflow"
+
 static int fmtfp (char *buffer, size_t *currlen, size_t maxlen,
                  LDOUBLE fvalue, int min, int max, int flags)
 {
-  int signvalue = 0;
+  char signvalue = 0;
   LDOUBLE ufvalue;
   char iconvert[24];
   char fconvert[24];
   size_t iplace = 0;
   size_t fplace = 0;
-  int padlen = 0; /* amount to pad */
-  int zpadlen = 0; 
+  long padlen = 0; /* amount to pad */
+  long zpadlen = 0; 
   int total = 0;
   LLONG intpart;
   LLONG fracpart;
@@ -688,7 +739,7 @@ static int fmtfp (char *buffer, size_t *currlen, size_t maxlen,
       if (intpart != 0)
        {
          /* For each digit of INTPART, print one less fractional digit. */
-         LLONG temp = intpart;
+         LLONG temp;
          for (temp = intpart; temp != 0; temp /= 10)
            --max;
          if (max < 0)
@@ -700,7 +751,7 @@ static int fmtfp (char *buffer, size_t *currlen, size_t maxlen,
             fractional digit. */
          LDOUBLE temp;
          if (ufvalue > 0)
-           for (temp = ufvalue; temp < 0.1; temp *= 10)
+           for (temp = ufvalue; temp < (LDOUBLE) 0.1; temp *= 10)
              ++max;
        }
     }
@@ -747,12 +798,16 @@ static int fmtfp (char *buffer, size_t *currlen, size_t maxlen,
       }
 
 #ifdef DEBUG_SNPRINTF
-  dprint (1, (debugfile, "fmtfp: %f =? %d.%d\n", fvalue, intpart, fracpart));
+# ifdef HAVE_LONG_LONG_INT
+  debug ("fmtfp: %Lf =? %lld.%lld\n", fvalue, intpart, fracpart);
+# else
+  debug ("fmtfp: %Lf =? %ld.%ld\n", fvalue, intpart, fracpart);
+# endif
 #endif
 
   /* Convert integer part */
   do {
-    iconvert[iplace++] = '0' + intpart % 10;
+    iconvert[iplace++] = (char) ('0' + (intpart % 10));
     intpart = (intpart / 10);
   } while(intpart && (iplace < sizeof(iconvert)));
   if (iplace == sizeof(iconvert)) iplace--;
@@ -760,7 +815,7 @@ static int fmtfp (char *buffer, size_t *currlen, size_t maxlen,
 
   /* Convert fractional part */
   do {
-    fconvert[fplace++] = '0' + fracpart % 10;
+    fconvert[fplace++] = (char) ('0' + (fracpart % 10));
     fracpart = (fracpart / 10);
   } while(fracpart && (fplace < sizeof(fconvert)));
   while (leadingfrac0s-- > 0 && fplace < sizeof(fconvert))
@@ -848,27 +903,14 @@ int vsnprintf (char *str, size_t count, const char *fmt, va_list args)
   return dopr(str, count, fmt, args);
 }
 
-/* VARARGS3 */
-#ifdef HAVE_STDARGS
-int snprintf (char *str,size_t count,const char *fmt,...)
-#else
-int snprintf (va_alist) va_dcl
-#endif
+int snprintf (char *str, size_t count, const char *fmt,...)
 {
-#ifndef HAVE_STDARGS
-  char *str;
-  size_t count;
-  char *fmt;
-#endif
-  VA_LOCAL_DECL;
+  va_list ap;
   int total;
     
-  VA_START (fmt);
-  VA_SHIFT (str, char *);
-  VA_SHIFT (count, size_t );
-  VA_SHIFT (fmt, char *);
+  va_start(ap, fmt);
   total = vsnprintf(str, count, fmt, ap);
-  VA_END;
+  va_end(ap);
   return total;
 }
 
@@ -945,5 +987,6 @@ int main (void)
       num++;
     }
   printf ("%d tests failed out of %d.\n", fail, num);
+  return 0;
 }
-#endif /* SNPRINTF_TEST */
+#endif /* TEST_SNPRINTF */
index 278288cef018815d5c9478ba9f7e440ba2181486..749052a61aa9a47c9f2682f27f9173807b7d12fd 100644 (file)
@@ -9,14 +9,15 @@
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2008, 2011
+ *     The Board of Trustees of the Leland Stanford Junior University
  *
- * The authors hereby relinquish any claim to any copyright that they may have
- * in this work, whether granted under contract or by operation of law or
- * international treaty, and hereby commit to the public, at large, that they
- * shall not, at any time in the future, seek to enforce any copyright in this
- * work against any person or entity, or prevent any person or entity from
- * copying, publishing, distributing or creating derivative works of this
- * work.
+ * Copying and distribution of this file, with or without modification, are
+ * permitted in any medium without royalty provided the copyright notice and
+ * this notice are preserved.  This file is offered as-is, without any
+ * warranty.
+ *
+ * SPDX-License-Identifier: FSFAP
  */
 
 #ifndef PORTABLE_STDBOOL_H
index 982e69188c97925e0fcbc500f49f936c02f0ce67..9ddcbc130c3360f3465a3202821a7e9aff67b328 100644 (file)
@@ -5,14 +5,15 @@
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2011-2012
+ *     The Board of Trustees of the Leland Stanford Junior University
  *
- * The authors hereby relinquish any claim to any copyright that they may have
- * in this work, whether granted under contract or by operation of law or
- * international treaty, and hereby commit to the public, at large, that they
- * shall not, at any time in the future, seek to enforce any copyright in this
- * work against any person or entity, or prevent any person or entity from
- * copying, publishing, distributing or creating derivative works of this
- * work.
+ * Copying and distribution of this file, with or without modification, are
+ * permitted in any medium without royalty provided the copyright notice and
+ * this notice are preserved.  This file is offered as-is, without any
+ * warranty.
+ *
+ * SPDX-License-Identifier: FSFAP
  */
 
 #include <config.h>
index 6912adeffb15c48eebe729e4abb45073e47505a8..e98d5642a2ddc14f80b6f724f6a08fd98813425a 100644 (file)
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2014, 2016, 2018, 2020 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2006-2011, 2013-2014
+ *     The Board of Trustees of the Leland Stanford Junior University
  *
- * The authors hereby relinquish any claim to any copyright that they may have
- * in this work, whether granted under contract or by operation of law or
- * international treaty, and hereby commit to the public, at large, that they
- * shall not, at any time in the future, seek to enforce any copyright in this
- * work against any person or entity, or prevent any person or entity from
- * copying, publishing, distributing or creating derivative works of this
- * work.
+ * Copying and distribution of this file, with or without modification, are
+ * permitted in any medium without royalty provided the copyright notice and
+ * this notice are preserved.  This file is offered as-is, without any
+ * warranty.
+ *
+ * SPDX-License-Identifier: FSFAP
  */
 
 #ifndef PORTABLE_SYSTEM_H
@@ -105,6 +107,16 @@ typedef ptrdiff_t ssize_t;
 #    endif
 #endif
 
+/*
+ * If explicit_bzero is not available, fall back on memset.  This does NOT
+ * provide any of the security guarantees of explicit_bzero and will probably
+ * be optimized away by the compiler.  It just ensures that code will compile
+ * and function on systems without explicit_bzero.
+ */
+#if !HAVE_EXPLICIT_BZERO
+#    define explicit_bzero(s, n) memset((s), 0, (n))
+#endif
+
 BEGIN_DECLS
 
 /* Default to a hidden visibility for all portability functions. */
@@ -118,14 +130,16 @@ BEGIN_DECLS
 #if !HAVE_ASPRINTF
 extern int asprintf(char **, const char *, ...)
     __attribute__((__format__(printf, 2, 3)));
-extern int vasprintf(char **, const char *, va_list);
+extern int vasprintf(char **, const char *, va_list)
+    __attribute__((__format__(printf, 2, 0)));
 #endif
 #if !HAVE_DECL_SNPRINTF
 extern int snprintf(char *, size_t, const char *, ...)
     __attribute__((__format__(printf, 3, 4)));
 #endif
 #if !HAVE_DECL_VSNPRINTF
-extern int vsnprintf(char *, size_t, const char *, va_list);
+extern int vsnprintf(char *, size_t, const char *, va_list)
+    __attribute__((__format__(printf, 3, 0)));
 #endif
 #if !HAVE_MKSTEMP
 extern int mkstemp(char *);
index e31a47d80d14a592f1943fc686dd5f99f5a2db59..186d2d5699b173f0f1e4f9f53fb00c274beedd76 100644 (file)
@@ -248,3 +248,5 @@ License
     are permitted in any medium without royalty provided the copyright
     notice and this notice are preserved.  This file is offered as-is,
     without any warranty.
+
+    SPDX-License-Identifier: FSFAP
index b2ff5f621c5ebc6b26ea84684fb957d8efbeaca2..3ecca1e36f737d0c8ad278e08fc40dc07bf50474 100644 (file)
@@ -1,6 +1,5 @@
 docs/pod
 docs/pod-spelling
-docs/urls
 plugin/heimdal
 plugin/mit
 perl/critic
@@ -10,6 +9,7 @@ portable/asprintf
 portable/mkstemp
 portable/snprintf
 portable/strndup
+style/obsolete-strings
 tools/heimdal-history
 tools/heimdal-strength
 tools/wordlist
index cf333762e49e79301565bf7637d60bf37f021cbe..60210a9e17fb5402095e3745e56e52b2f97458df 100644 (file)
@@ -4,13 +4,14 @@
 # for packages that run perlcritic tests automatically during the build for
 # reproducible test results.
 #
-# This file has been updated to match perlcritic 1.118.
+# This file has been updated to match perlcritic 1.134.
 #
 # The canonical version of this file is maintained in the rra-c-util package,
 # which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
 #
 # Written by Russ Allbery <eagle@eyrie.org>
-# Copyright 2011, 2012, 2013
+# Copyright 2018-2019 Russ Allbery <eagle@eyrie.org>
+# Copyright 2011-2013
 #     The Board of Trustees of the Leland Stanford Junior University
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
@@ -30,6 +31,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
 
 severity = 1
 verbose  = %f:%l:%c: [%p] %m (%e, Severity: %s)\n
@@ -49,9 +52,6 @@ allow = unless
 # This is handled with a separate test case that uses Test::Spelling.
 [-Documentation::PodSpelling]
 
-# Pod::Man and Pod::Text fixed this bug years ago.  I know, I maintain them.
-[-Documentation::RequirePodLinksIncludeText]
-
 # The POD sections Perl::Critic wants are incompatible with the POD template
 # from perlpodstyle, which is what I use for my POD documentation.
 [-Documentation::RequirePodSections]
@@ -75,6 +75,10 @@ lines = 25
 # off.
 [-RegularExpressions::ProhibitComplexRegexes]
 
+# Produces false positives currently with postfix dereferencing (introduced in
+# Perl 5.20).  See https://github.com/Perl-Critic/Perl-Critic/issues/578.
+[-References::ProhibitDoubleSigils]
+
 # I generally don't want to require Readonly as a prerequisite for all my Perl
 # modules.
 [-ValuesAndExpressions::ProhibitConstantPragma]
@@ -89,9 +93,10 @@ lines = 25
 [ValuesAndExpressions::RequireNumberSeparators]
 min_value = 100000
 
+# IO::Uncompress::Gunzip puts the error message in a package variable.
 # Text::Wrap has a broken interface that requires use of package variables.
 [Variables::ProhibitPackageVars]
-add_packages = Text::Wrap
+add_packages = IO::Uncompress::Gunzip Text::Wrap
 
 # use English was one of the worst ideas in the history of Perl.  It makes the
 # code slightly more readable for amateurs at the cost of confusing
index e35e8a8fe2144a7bab20cab26f52b94c008f19e7..c2d0e40f04e06214fd6421a49cdccf6186bd16ce 100644 (file)
@@ -4,6 +4,17 @@
 #
 # The canonical version of this file is maintained in the rra-c-util package,
 # which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
+#
+# Written by Russ Allbery <eagle@eyrie.org>
+# Copyright 2012-2013
+#     The Board of Trustees of the Leland Stanford Junior University
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice and
+# this notice are preserved.  This file is offered as-is, without any
+# warranty.
+#
+# SPDX-License-Identifier: FSFAP
 
 -bbao           # put line breaks before any operator
 -nbbc           # don't force blank lines before comments (bad for else blocks)
index c5a2e5dbef43dde1ac2ef332d61bdca9f9915650..5c1005445f2605a2c95ecd4f1cb3f335af8d9f91 100644 (file)
@@ -11,7 +11,8 @@
 # which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
 #
 # Written by Russ Allbery <eagle@eyrie.org>
-# Copyright 2011, 2012, 2013, 2014
+# Copyright 2017-2018 Russ Allbery <eagle@eyrie.org>
+# Copyright 2011-2014
 #     The Board of Trustees of the Leland Stanford Junior University
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
@@ -31,6 +32,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
 
 {
    dlopen-dlerror
    fun:calloc
    fun:_dlerror_run
 }
+{
+   fakeroot-msgsnd
+   Memcheck:Param
+   msgsnd(msgp->mtext)
+   fun:msgsnd
+   fun:send_fakem
+   fun:send_get_fakem
+   obj:*/libfakeroot-sysv.so
+}
+{
+   heimdal-base-once
+   Memcheck:Leak
+   fun:*alloc
+   ...
+   fun:heim_base_once_f
+}
 {
    heimdal-gss-config
    Memcheck:Leak
    ...
    fun:krb5_gss_save_error_string
 }
+{
+   mit-gss-mechs
+   Memcheck:Leak
+   fun:glob
+   fun:loadConfigFiles
+   fun:updateMechList
+   fun:build_mechSet
+   fun:gss_indicate_mechs
+}
+{
+   mit-kadmin-ovku-error
+   Memcheck:Leak
+   fun:*alloc*
+   fun:initialize_ovku_error_table_r
+}
+{
+   mit-krb5-changepw
+   Memcheck:Leak
+   fun:*alloc
+   fun:change_set_password
+   fun:krb5_change_password
+   fun:krb5_get_init_creds_password
+}
 {
    mit-krb5-pkinit-openssl-init
    Memcheck:Leak
    ...
    fun:krb5_preauth_request_context_init
 }
+{
+   mit-krb5-pkinit-openssl-request-2
+   Memcheck:Leak
+   fun:*alloc
+   ...
+   fun:k5_preauth_request_context_init
+}
 {
    mit-krb5-plugin-dirs
    Memcheck:Leak
    fun:strdup
    fun:register_module.isra.1
 }
+{
+   mit-krb5-preauth-init
+   Memcheck:Leak
+   fun:*alloc
+   ...
+   fun:k5_init_preauth_context
+}
+{
+   mit-krb5-preauth-init
+   Memcheck:Leak
+   fun:strdup
+   fun:add_to_list
+   fun:profile_get_values
+   ...
+   fun:clpreauth_prep_questions
+}
+{
+   mit-krb5-preauth-init-2
+   Memcheck:Leak
+   fun:*alloc
+   fun:init_list
+   fun:profile_get_values
+   ...
+   fun:clpreauth_prep_questions
+}
+{
+   mit-krb5-profile
+   Memcheck:Leak
+   fun:*alloc
+   ...
+   fun:profile_open_file
+}
 {
    portable-setenv
    Memcheck:Leak
index 729d96e757abfd78e9d3741d64e7eee4151c83a6..04a89e5bc80a5206f2a966508fd6cb6e77709968 100755 (executable)
@@ -6,8 +6,8 @@
 # which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
 #
 # Written by Russ Allbery <eagle@eyrie.org>
-# Copyright 2016 Russ Allbery <eagle@eyrie.org>
-# Copyright 2012, 2013, 2014
+# Copyright 2016, 2019 Russ Allbery <eagle@eyrie.org>
+# Copyright 2012-2014
 #     The Board of Trustees of the Leland Stanford Junior University
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
 # 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
 
-use 5.006;
+use 5.008;
 use strict;
 use warnings;
 
 use lib "$ENV{C_TAP_SOURCE}/tap/perl";
 
-use Test::More;
 use Test::RRA qw(skip_unless_author use_prereq);
 use Test::RRA::Automake qw(automake_setup perl_dirs);
 
+use Test::More;
+
 # Only run this test for the module author since the required stopwords are
 # too sensitive to the exact spell-checking program and dictionary.
 skip_unless_author('Spelling tests');
index 0bd5b430e7eeed997c10504ce14406725415ad06..7b53dda341ea5fe4e79628850087ee79ef88c2b5 100755 (executable)
@@ -7,8 +7,8 @@
 # which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
 #
 # Written by Russ Allbery <eagle@eyrie.org>
-# Copyright 2016 Russ Allbery <eagle@eyrie.org>
-# Copyright 2012, 2013, 2014
+# Copyright 2016, 2019 Russ Allbery <eagle@eyrie.org>
+# Copyright 2012-2014
 #     The Board of Trustees of the Leland Stanford Junior University
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
 # 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
 
-use 5.006;
+use 5.008;
 use strict;
 use warnings;
 
 use lib "$ENV{C_TAP_SOURCE}/tap/perl";
 
-use Test::More;
 use Test::RRA qw(skip_unless_automated use_prereq);
 use Test::RRA::Automake qw(automake_setup perl_dirs);
 
+use Test::More;
+
 # Skip this test for normal user installs, since we normally pre-generate all
 # of the documentation and the end user doesn't care.
 skip_unless_automated('POD syntax tests');
index b5593e4caf591b24fc62609496a75dff3e4b105b..6f6e680ba3adc104de8657c8d84f618a1f7d07ac 100755 (executable)
@@ -6,8 +6,8 @@
 # which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
 #
 # Written by Russ Allbery <eagle@eyrie.org>
-# Copyright 2016 Russ Allbery <eagle@eyrie.org>
-# Copyright 2012, 2013, 2014
+# Copyright 2016, 2019 Russ Allbery <eagle@eyrie.org>
+# Copyright 2012-2014
 #     The Board of Trustees of the Leland Stanford Junior University
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
 # 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
 
-use 5.006;
+use 5.008;
 use strict;
 use warnings;
 
 use lib "$ENV{C_TAP_SOURCE}/tap/perl";
 
-use File::Spec;
-use Test::More;
 use Test::RRA qw(skip_unless_author use_prereq);
 use Test::RRA::Automake qw(automake_setup perl_dirs test_file_path);
 use Test::RRA::Config qw(@CRITIC_IGNORE);
 
+use File::Spec;
+use Test::More;
+
 # Skip tests unless we're running author tests since this test is too
 # sensitive to the exact version of Perl::Critic to be generally useful.
 skip_unless_author('Coding style tests');
index acdb13116783f42ec364f3a881089a697fa85f9c..420ce36d8406f8c75bfb91df263469c7698423f0 100755 (executable)
@@ -10,8 +10,8 @@
 # which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
 #
 # Written by Russ Allbery <eagle@eyrie.org>
-# Copyright 2016 Russ Allbery <eagle@eyrie.org>
-# Copyright 2012, 2013, 2014
+# Copyright 2016, 2019-2020 Russ Allbery <eagle@eyrie.org>
+# Copyright 2012-2014
 #     The Board of Trustees of the Leland Stanford Junior University
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
 # 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
 
-use 5.006;
+use 5.008;
 use strict;
 use warnings;
 
 use lib "$ENV{C_TAP_SOURCE}/tap/perl";
 
-use Test::More;
 use Test::RRA qw(skip_unless_automated use_prereq);
 use Test::RRA::Automake qw(automake_setup perl_dirs);
 use Test::RRA::Config qw($MINIMUM_VERSION %MINIMUM_VERSION);
 
+use Test::More;
+
 # Skip for normal user installs since this doesn't affect functionality.
 skip_unless_automated('Minimum version tests');
 
@@ -53,7 +56,7 @@ use_prereq('Test::MinimumVersion');
 automake_setup();
 
 # For each exception case in %MINIMUM_VERSION, check the files that should
-# have that minium version.  Sort for reproducible test order.  Also
+# have that minimum version.  Sort for reproducible test order.  Also
 # accumulate the list of directories we've already tested.
 my @tested;
 for my $version (sort keys %MINIMUM_VERSION) {
index 58a7cf7db5ac04035e9e3e38e5009c5f87ce6dea..6eae21654f8acc8da4f8909e1283cb6182bde0e0 100755 (executable)
@@ -10,8 +10,8 @@
 # which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
 #
 # Written by Russ Allbery <eagle@eyrie.org>
-# Copyright 2016 Russ Allbery <eagle@eyrie.org>
-# Copyright 2012, 2013, 2014
+# Copyright 2016, 2019 Russ Allbery <eagle@eyrie.org>
+# Copyright 2012-2014
 #     The Board of Trustees of the Leland Stanford Junior University
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
 # 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
 
-use 5.006;
+use 5.008;
 use strict;
 use warnings;
 
 use lib "$ENV{C_TAP_SOURCE}/tap/perl";
 
-use Test::More;
 use Test::RRA qw(skip_unless_automated use_prereq);
 use Test::RRA::Automake qw(automake_setup perl_dirs);
 use Test::RRA::Config qw(@STRICT_IGNORE @STRICT_PREREQ);
 
+use Test::More;
+
 # Skip for normal user installs since this doesn't affect functionality.
 skip_unless_automated('Strictness tests');
 
index 4f7a6f617ae3262ba1ee5c6e56f361fa56bfefb8..3b10a6622c315d2457841e0bfdf8397a02990e7e 100644 (file)
@@ -5,14 +5,16 @@
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2014, 2018 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2006-2009, 2011
+ *     The Board of Trustees of the Leland Stanford Junior University
  *
- * The authors hereby relinquish any claim to any copyright that they may have
- * in this work, whether granted under contract or by operation of law or
- * international treaty, and hereby commit to the public, at large, that they
- * shall not, at any time in the future, seek to enforce any copyright in this
- * work against any person or entity, or prevent any person or entity from
- * copying, publishing, distributing or creating derivative works of this
- * work.
+ * Copying and distribution of this file, with or without modification, are
+ * permitted in any medium without royalty provided the copyright notice and
+ * this notice are preserved.  This file is offered as-is, without any
+ * warranty.
+ *
+ * SPDX-License-Identifier: FSFAP
  */
 
 #include <config.h>
 
 int test_asprintf(char **, const char *, ...)
     __attribute__((__format__(printf, 2, 3)));
-int test_vasprintf(char **, const char *, va_list);
+int test_vasprintf(char **, const char *, va_list)
+    __attribute__((__format__(printf, 2, 0)));
 
-static int
+static int __attribute__((__format__(printf, 2, 3)))
 vatest(char **result, const char *format, ...)
 {
     va_list args;
index 5899a388c3d87ad9f2db41284c8346c0b69c32ac..dc268210f063d783e89f70f5cf7b5da8d594d902 100644 (file)
@@ -5,14 +5,15 @@
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2009, 2011
+ *     The Board of Trustees of the Leland Stanford Junior University
  *
- * The authors hereby relinquish any claim to any copyright that they may have
- * in this work, whether granted under contract or by operation of law or
- * international treaty, and hereby commit to the public, at large, that they
- * shall not, at any time in the future, seek to enforce any copyright in this
- * work against any person or entity, or prevent any person or entity from
- * copying, publishing, distributing or creating derivative works of this
- * work.
+ * Copying and distribution of this file, with or without modification, are
+ * permitted in any medium without royalty provided the copyright notice and
+ * this notice are preserved.  This file is offered as-is, without any
+ * warranty.
+ *
+ * SPDX-License-Identifier: FSFAP
  */
 
 #include <config.h>
index 26db70a379d9d970a2623597c029873688daf604..30bcd3706596e6ddded64ca88fbdef23470087a8 100644 (file)
@@ -8,14 +8,16 @@
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2014 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2014
+ *     The Board of Trustees of the Leland Stanford Junior University
  *
- * The authors hereby relinquish any claim to any copyright that they may have
- * in this work, whether granted under contract or by operation of law or
- * international treaty, and hereby commit to the public, at large, that they
- * shall not, at any time in the future, seek to enforce any copyright in this
- * work against any person or entity, or prevent any person or entity from
- * copying, publishing, distributing or creating derivative works of this
- * work.
+ * Copying and distribution of this file, with or without modification, are
+ * permitted in any medium without royalty provided the copyright notice and
+ * this notice are preserved.  This file is offered as-is, without any
+ * warranty.
+ *
+ * SPDX-License-Identifier: FSFAP
  */
 
 #include <config.h>
index 6efaf53ec3195d3ee90ed929f32d46d43b2bf023..d14712f914d902ca78a788534f3caa6b982fb611 100644 (file)
@@ -5,9 +5,8 @@
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006
- *     Russ Allbery <eagle@eyrie.org>
- * Copyright 2009, 2010
+ * Copyright 2000-2006, 2018-2020 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2009-2010
  *     The Board of Trustees of the Leland Stanford Junior University
  * Copyright 1995 Patrick Powell
  * Copyright 2001 Hrvoje Niksic
@@ -15,6 +14,8 @@
  * This code is based on code written by Patrick Powell (papowell@astart.com)
  * It may be used for any purpose as long as this notice remains intact
  * on all source code distributions
+ *
+ * There is no SPDX-License-Identifier registered for this license.
  */
 
 #include <config.h>
@@ -39,56 +40,58 @@ int test_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
 
 static const char string[] = "abcdefghijklmnopqrstuvwxyz0123456789";
 
+/* clang-format off */
+
 static const char *const fp_formats[] = {
-    "%-1.5f", "%1.5f", "%31.9f", "%10.5f", "% 10.5f", "%+22.9f", "%+4.9f",
-    "%01.3f", "%3.1f", "%3.2f",  "%.0f",   "%.1f",    "%f",
-
-/* %e and %g formats aren't really implemented yet. */
-#if 0
-    "%-1.5e",   "%1.5e",    "%31.9e",   "%10.5e",   "% 10.5e",  "%+22.9e",
-    "%+4.9e",   "%01.3e",   "%3.1e",    "%3.2e",    "%.0e",     "%.1e",
-    "%e",
-    "%-1.5g",   "%1.5g",    "%31.9g",   "%10.5g",   "% 10.5g",  "%+22.9g",
-    "%+4.9g",   "%01.3g",   "%3.1g",    "%3.2g",    "%.0g",     "%.1g",
-    "%g",
-#endif
-    NULL};
+    "%-1.5f",   "%1.5f",    "%31.6f",   "%10.5f",   "% 10.5f",  "%+22.6f",
+    "%+4.6f",   "%01.3f",   "%3.1f",    "%3.2f",    "%.0f",     "%.1f",
+    "%f",
+    NULL
+};
 static const char *const int_formats[] = {
-    "%-1.5d",   "%1.5d",  "%31.9d", "%5.5d", "%10.5d", "% 10.5d",
-    "%+22.30d", "%01.3d", "%4d",    "%d",    "%ld",    NULL};
+    "%-1.5d",   "%1.5d",    "%31.9d",   "%5.5d",    "%10.5d",   "% 10.5d",
+    "%+22.30d", "%01.3d",   "%4d",      "%d",       "%ld",      NULL
+};
 static const char *const uint_formats[] = {
-    "%-1.5lu",  "%1.5lu",   "%31.9lu", "%5.5lu", "%10.5lu",
-    "% 10.5lu", "%+6.30lu", "%01.3lu", "%4lu",   "%lu",
-    "%4lx",     "%4lX",     "%01.3lx", "%1lo",   NULL};
+    "%-1.5lu",  "%1.5lu",   "%31.9lu",  "%5.5lu",   "%10.5lu",  "% 10.5lu",
+    "%+6.30lu", "%01.3lu",  "%4lu",     "%lu",      "%4lx",     "%4lX",
+    "%01.3lx",  "%1lo",     NULL
+};
 static const char *const llong_formats[] = {
-    "%lld",      "%-1.5lld",   "%1.5lld",  "%123.9lld", "%5.5lld", "%10.5lld",
-    "% 10.5lld", "%+22.33lld", "%01.3lld", "%4lld",     NULL};
+    "%lld",     "%-1.5lld",  "%1.5lld",    "%123.9lld",  "%5.5lld",
+    "%10.5lld", "% 10.5lld", "%+22.33lld", "%01.3lld",   "%4lld",
+    NULL
+};
 static const char *const ullong_formats[] = {
-    "%llu",     "%-1.5llu",  "%1.5llu",    "%123.9llu", "%5.5llu",
-    "%10.5llu", "% 10.5llu", "%+22.33llu", "%01.3llu",  "%4llu",
-    "%llx",     "%llo",      NULL};
-
-static const double fp_nums[] = {-1.5, 134.21, 91340.2, 341.1234, 0203.9,
-                                 0.96, 0.996,  0.9996,  1.996,    4.136,
-                                 0.1,  0.01,   0.001,   10.1,     0};
-static long int_nums[] = {-1, 134, 91340, 341, 0203, 0};
+    "%llu",     "%-1.5llu",  "%1.5llu",    "%123.9llu",  "%5.5llu",
+    "%10.5llu", "% 10.5llu", "%+22.33llu", "%01.3llu",   "%4llu",
+    "%llx",     "%llo",      NULL
+};
+
+static const double fp_nums[] = {
+    -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996, 0.9996, 1.996,
+    4.136, 0.1, 0.01, 0.001, 10.1, 0
+};
+static long int_nums[] = {
+    -1, 134, 91340, 341, 0203, 0
+};
 static unsigned long uint_nums[] = {
-    (unsigned long) -1, 134, 91340, 341, 0203, 0};
-static long long llong_nums[] = {~(long long) 0, /* All-1 bit pattern. */
-                                 (~(unsigned long long) 0)
-                                     >> 1, /* Largest signed long long. */
-                                 -150,
-                                 134,
-                                 91340,
-                                 341,
-                                 0};
+    (unsigned long) -1, 134, 91340, 341, 0203, 0
+};
+static long long llong_nums[] = {
+    ~(long long) 0,                     /* All-1 bit pattern. */
+    (~(unsigned long long) 0) >> 1,     /* Largest signed long long. */
+    -150, 134, 91340, 341,
+    0
+};
 static unsigned long long ullong_nums[] = {
-    ~(unsigned long long) 0,        /* All-1 bit pattern. */
-    (~(unsigned long long) 0) >> 1, /* Largest signed long long. */
-    134,
-    91340,
-    341,
-    0};
+    ~(unsigned long long) 0,            /* All-1 bit pattern. */
+    (~(unsigned long long) 0) >> 1,     /* Largest signed long long. */
+    134, 91340, 341,
+    0
+};
+
+/* clang-format on */
 
 
 static void
@@ -152,7 +155,7 @@ main(void)
                 string, &lcount);
     is_int(0, count, "correct output from two %%n");
     is_int(31, lcount, "correct output from long %%ln");
-    test_format(true, "(null)", 6, "%s", NULL);
+    test_format(true, "(null)", 6, "%s", (char *) NULL);
 
     for (i = 0; fp_formats[i] != NULL; i++)
         for (j = 0; j < ARRAY_SIZE(fp_nums); j++) {
index c08786f9974a9e925417d4a927eee9f6a4d5f807..9bf28a31beec9b81325f76c56151b553abd48211 100644 (file)
@@ -5,14 +5,16 @@
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2018 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2011-2012
+ *     The Board of Trustees of the Leland Stanford Junior University
  *
- * The authors hereby relinquish any claim to any copyright that they may have
- * in this work, whether granted under contract or by operation of law or
- * international treaty, and hereby commit to the public, at large, that they
- * shall not, at any time in the future, seek to enforce any copyright in this
- * work against any person or entity, or prevent any person or entity from
- * copying, publishing, distributing or creating derivative works of this
- * work.
+ * Copying and distribution of this file, with or without modification, are
+ * permitted in any medium without royalty provided the copyright notice and
+ * this notice are preserved.  This file is offered as-is, without any
+ * warranty.
+ *
+ * SPDX-License-Identifier: FSFAP
  */
 
 #include <config.h>
@@ -29,7 +31,7 @@ int
 main(void)
 {
     char buffer[3];
-    char *result = NULL;
+    char *result;
 
     plan(7);
 
index ef78733ad8d846c4b9e857e466f6f97f99bbe83a..1050120c7f084405b20ad02d584f1b1440a2ffcd 100644 (file)
@@ -1,6 +1,37 @@
 /*
  * Run a set of tests, reporting results.
  *
+ * Test suite driver that runs a set of tests implementing a subset of the
+ * Test Anything Protocol (TAP) and reports the results.
+ *
+ * Any bug reports, bug fixes, and improvements are very much welcome and
+ * should be sent to the e-mail address below.  This program is part of C TAP
+ * Harness <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
+ *
+ * Copyright 2000-2001, 2004, 2006-2019 Russ Allbery <eagle@eyrie.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * 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
+ */
+
+/*
  * Usage:
  *
  *      runtests [-hv] [-b <build-dir>] [-s <source-dir>] -l <test-list>
@@ -8,9 +39,10 @@
  *      runtests -o [-h] [-b <build-dir>] [-s <source-dir>] <test>
  *
  * In the first case, expects a list of executables located in the given file,
- * one line per executable.  For each one, runs it as part of a test suite,
- * reporting results.  In the second case, use the same infrastructure, but
- * run only the tests listed on the command line.
+ * one line per executable, possibly followed by a space-separated list of
+ * options.  For each one, runs it as part of a test suite, reporting results.
+ * In the second case, use the same infrastructure, but run only the tests
+ * listed on the command line.
  *
  * Test output should start with a line containing the number of tests
  * (numbered from 1 to this number), optionally preceded by "1..", although
  * If the -v option is given, or the C_TAP_VERBOSE environment variable is set,
  * display the full output of each test as it runs rather than showing a
  * summary of the results of each test.
- *
- * Any bug reports, bug fixes, and improvements are very much welcome and
- * should be sent to the e-mail address below.  This program is part of C TAP
- * Harness <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
- *
- * Copyright 2000, 2001, 2004, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013,
- *     2014, 2015, 2016 Russ Allbery <eagle@eyrie.org>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * 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.
  */
 
 /* Required for fdopen(), getopt(), and putenv(). */
@@ -171,7 +178,7 @@ enum plan_status {
 /* Structure to hold data for a set of tests. */
 struct testset {
     char *file;                /* The file name of the test. */
-    char *path;                /* The path to the test program. */
+    char **command;            /* The argv vector to run the command. */
     enum plan_status plan;     /* The status of our plan. */
     unsigned long count;       /* Expected count of tests. */
     unsigned long current;     /* The last seen test number. */
@@ -182,7 +189,7 @@ struct testset {
     unsigned long allocated;   /* The size of the results table. */
     enum test_status *results; /* Table of results by test number. */
     unsigned int aborted;      /* Whether the set was aborted. */
-    int reported;              /* Whether the results were reported. */
+    unsigned int reported;     /* Whether the results were reported. */
     int status;                /* The exit status of the test. */
     unsigned int all_skipped;  /* Whether all tests were skipped. */
     char *reason;              /* Why all tests were skipped. */
@@ -231,11 +238,13 @@ Failed Set                 Fail/Total (%) Skip Stat  Failing Tests\n\
 -------------------------- -------------- ---- ----  ------------------------";
 
 /* Include the file name and line number in malloc failures. */
-#define xcalloc(n, size) x_calloc((n), (size), __FILE__, __LINE__)
-#define xmalloc(size)    x_malloc((size), __FILE__, __LINE__)
-#define xstrdup(p)       x_strdup((p), __FILE__, __LINE__)
-#define xreallocarray(p, n, size) \
-    x_reallocarray((p), (n), (size), __FILE__, __LINE__)
+#define xcalloc(n, type) \
+    ((type *) x_calloc((n), sizeof(type), __FILE__, __LINE__))
+#define xmalloc(size)     ((char *) x_malloc((size), __FILE__, __LINE__))
+#define xstrdup(p)        x_strdup((p), __FILE__, __LINE__)
+#define xstrndup(p, size) x_strndup((p), (size), __FILE__, __LINE__)
+#define xreallocarray(p, n, type) \
+    ((type *) x_reallocarray((p), (n), sizeof(type), __FILE__, __LINE__))
 
 /*
  * __attribute__ is available in gcc 2.5 and later, but only with gcc 2.7
@@ -274,6 +283,8 @@ Failed Set                 Fail/Total (%) Skip Stat  Failing Tests\n\
 #endif
 
 /* Declare internal functions that benefit from compiler attributes. */
+static void die(const char *, ...)
+    __attribute__((__nonnull__, __noreturn__, __format__(printf, 1, 2)));
 static void sysdie(const char *, ...)
     __attribute__((__nonnull__, __noreturn__, __format__(printf, 1, 2)));
 static void *x_calloc(size_t, size_t, const char *, int)
@@ -284,6 +295,26 @@ static void *x_reallocarray(void *, size_t, size_t, const char *, int)
     __attribute__((__alloc_size__(2, 3), __malloc__, __nonnull__(4)));
 static char *x_strdup(const char *, const char *, int)
     __attribute__((__malloc__, __nonnull__));
+static char *x_strndup(const char *, size_t, const char *, int)
+    __attribute__((__malloc__, __nonnull__));
+
+
+/*
+ * Report a fatal error and exit.
+ */
+static void
+die(const char *format, ...)
+{
+    va_list args;
+
+    fflush(stdout);
+    fprintf(stderr, "runtests: ");
+    va_start(args, format);
+    vfprintf(stderr, format, args);
+    va_end(args);
+    fprintf(stderr, "\n");
+    exit(1);
+}
 
 
 /*
@@ -356,6 +387,9 @@ x_malloc(size_t size, const char *file, int line)
 static void *
 x_reallocarray(void *p, size_t n, size_t size, const char *file, int line)
 {
+    n = (n > 0) ? n : 1;
+    size = (size > 0) ? size : 1;
+
     if (n > 0 && UINT_MAX / n <= size)
         sysdie("realloc too large at %s line %d", file, line);
     p = realloc(p, n * size);
@@ -376,7 +410,7 @@ x_strdup(const char *s, const char *file, int line)
     size_t len;
 
     len = strlen(s) + 1;
-    p = malloc(len);
+    p = (char *) malloc(len);
     if (p == NULL)
         sysdie("failed to strdup %lu bytes at %s line %d", (unsigned long) len,
                file, line);
@@ -385,6 +419,35 @@ x_strdup(const char *s, const char *file, int line)
 }
 
 
+/*
+ * Copy the first n characters of a string, reporting a fatal error and
+ * existing on failure.
+ *
+ * Avoid using the system strndup function since it may not exist (on Mac OS
+ * X, for example), and there's no need to introduce another portability
+ * requirement.
+ */
+char *
+x_strndup(const char *s, size_t size, const char *file, int line)
+{
+    const char *p;
+    size_t len;
+    char *copy;
+
+    /* Don't assume that the source string is nul-terminated. */
+    for (p = s; (size_t)(p - s) < size && *p != '\0'; p++)
+        ;
+    len = (size_t)(p - s);
+    copy = (char *) malloc(len + 1);
+    if (copy == NULL)
+        sysdie("failed to strndup %lu bytes at %s line %d",
+               (unsigned long) len, file, line);
+    memcpy(copy, s, len);
+    copy[len] = '\0';
+    return copy;
+}
+
+
 /*
  * Form a new string by concatenating multiple strings.  The arguments must be
  * terminated by (const char *) 0.
@@ -441,7 +504,7 @@ concat(const char *first, ...)
 static double
 tv_seconds(const struct timeval *tv)
 {
-    return difftime(tv->tv_sec, 0) + tv->tv_usec * 1e-6;
+    return difftime(tv->tv_sec, 0) + (double) tv->tv_usec * 1e-6;
 }
 
 
@@ -478,13 +541,26 @@ skip_whitespace(const char *p)
 }
 
 
+/*
+ * Given a pointer to a string, skip any non-whitespace characters and return
+ * a pointer to the first whitespace character, or to the end of the string.
+ */
+static const char *
+skip_non_whitespace(const char *p)
+{
+    while (*p != '\0' && !isspace((unsigned char) (*p)))
+        p++;
+    return p;
+}
+
+
 /*
  * Start a program, connecting its stdout to a pipe on our end and its stderr
  * to /dev/null, and storing the file descriptor to read from in the two
  * argument.  Returns the PID of the new process.  Errors are fatal.
  */
 static pid_t
-test_start(const char *path, int *fd)
+test_start(char *const *command, int *fd)
 {
     int fds[2], infd, errfd;
     pid_t child;
@@ -535,8 +611,9 @@ test_start(const char *path, int *fd)
         }
 
         /* Now, exec our process. */
-        if (execl(path, path, (char *) 0) == -1)
+        if (execv(command[0], command) == -1)
             _exit(CHILDERR_EXEC);
+        break;
 
     /* In parent.  Close the extra file descriptor. */
     default:
@@ -589,10 +666,10 @@ resize_results(struct testset *ts, unsigned long n)
      */
     if (ts->allocated == 0) {
         s = (n > 32) ? n : 32;
-        ts->results = xcalloc(s, sizeof(enum test_status));
+        ts->results = xcalloc(s, enum test_status);
     } else {
         s = (n > ts->allocated + 1024) ? n : ts->allocated + 1024;
-        ts->results = xreallocarray(ts->results, s, sizeof(enum test_status));
+        ts->results = xreallocarray(ts->results, s, enum test_status);
     }
 
     /* Set the results for the newly-allocated test array. */
@@ -1035,7 +1112,7 @@ test_run(struct testset *ts, enum test_verbose verbose)
     char buffer[BUFSIZ];
 
     /* Run the test program. */
-    testpid = test_start(ts->path, &outfd);
+    testpid = test_start(ts->command, &outfd);
     output = fdopen(outfd, "r");
     if (!output) {
         puts("ABORTED");
@@ -1097,6 +1174,7 @@ test_fail_summary(const struct testlist *fails)
     struct testset *ts;
     unsigned int chars;
     unsigned long i, first, last, total;
+    double failed;
 
     puts(header);
 
@@ -1105,8 +1183,10 @@ test_fail_summary(const struct testlist *fails)
     for (; fails; fails = fails->next) {
         ts = fails->ts;
         total = ts->count - ts->skipped;
+        failed = (double) ts->failed;
         printf("%-26.26s %4lu/%-4lu %3.0f%% %4lu ", ts->file, ts->failed,
-               total, total ? (ts->failed * 100.0) / total : 0, ts->skipped);
+               total, total ? (failed * 100.0) / (double) total : 0,
+               ts->skipped);
         if (WIFEXITED(ts->status))
             printf("%4d  ", WEXITSTATUS(ts->status));
         else
@@ -1201,6 +1281,96 @@ find_test(const char *name, const char *source, const char *build)
 }
 
 
+/*
+ * Parse a single line of a test list and store the test name and command to
+ * execute it in the given testset struct.
+ *
+ * Normally, each line is just the name of the test, which is located in the
+ * test directory and turned into a command to run.  However, each line may
+ * have whitespace-separated options, which change the command that's run.
+ * Current supported options are:
+ *
+ * valgrind
+ *     Run the test under valgrind if C_TAP_VALGRIND is set.  The contents
+ *     of that environment variable are taken as the valgrind command (with
+ *     options) to run.  The command is parsed with a simple split on
+ *     whitespace and no quoting is supported.
+ *
+ * libtool
+ *     If running under valgrind, use libtool to invoke valgrind.  This avoids
+ *     running valgrind on the wrapper shell script generated by libtool.  If
+ *     set, C_TAP_LIBTOOL must be set to the full path to the libtool program
+ *     to use to run valgrind and thus the test.  Ignored if the test isn't
+ *     being run under valgrind.
+ */
+static void
+parse_test_list_line(const char *line, struct testset *ts, const char *source,
+                     const char *build)
+{
+    const char *p, *end, *option, *libtool;
+    const char *valgrind = NULL;
+    unsigned int use_libtool = 0;
+    unsigned int use_valgrind = 0;
+    size_t len, i;
+
+    /* Determine the name of the test. */
+    p = skip_non_whitespace(line);
+    ts->file = xstrndup(line, p - line);
+
+    /* Check if any test options are set. */
+    p = skip_whitespace(p);
+    while (*p != '\0') {
+        end = skip_non_whitespace(p);
+        if (strncmp(p, "libtool", end - p) == 0) {
+            use_libtool = 1;
+        } else if (strncmp(p, "valgrind", end - p) == 0) {
+            valgrind = getenv("C_TAP_VALGRIND");
+            use_valgrind = (valgrind != NULL);
+        } else {
+            option = xstrndup(p, end - p);
+            die("unknown test list option %s", option);
+        }
+        p = skip_whitespace(end);
+    }
+
+    /* Construct the argv to run the test.  First, find the length. */
+    len = 1;
+    if (use_valgrind && valgrind != NULL) {
+        p = skip_whitespace(valgrind);
+        while (*p != '\0') {
+            len++;
+            p = skip_whitespace(skip_non_whitespace(p));
+        }
+        if (use_libtool)
+            len += 2;
+    }
+
+    /* Now, build the command. */
+    ts->command = xcalloc(len + 1, char *);
+    i = 0;
+    if (use_valgrind && valgrind != NULL) {
+        if (use_libtool) {
+            libtool = getenv("C_TAP_LIBTOOL");
+            if (libtool == NULL)
+                die("valgrind with libtool requested, but C_TAP_LIBTOOL is not"
+                    " set");
+            ts->command[i++] = xstrdup(libtool);
+            ts->command[i++] = xstrdup("--mode=execute");
+        }
+        p = skip_whitespace(valgrind);
+        while (*p != '\0') {
+            end = skip_non_whitespace(p);
+            ts->command[i++] = xstrndup(p, end - p);
+            p = skip_whitespace(end);
+        }
+    }
+    if (i != len - 1)
+        die("internal error while constructing command line");
+    ts->command[i++] = find_test(ts->file, source, build);
+    ts->command[i] = NULL;
+}
+
+
 /*
  * Read a list of tests from a file, returning the list of tests as a struct
  * testlist, or NULL if there were no tests (such as a file containing only
@@ -1208,17 +1378,17 @@ find_test(const char *name, const char *source, const char *build)
  * tests cannot be read.
  */
 static struct testlist *
-read_test_list(const char *filename)
+read_test_list(const char *filename, const char *source, const char *build)
 {
     FILE *file;
     unsigned int line;
     size_t length;
     char buffer[BUFSIZ];
-    const char *testname;
+    const char *start;
     struct testlist *listhead, *current;
 
     /* Create the initial container list that will hold our results. */
-    listhead = xcalloc(1, sizeof(struct testlist));
+    listhead = xcalloc(1, struct testlist);
     current = NULL;
 
     /*
@@ -1239,22 +1409,24 @@ read_test_list(const char *filename)
         buffer[length] = '\0';
 
         /* Skip comments, leading spaces, and blank lines. */
-        testname = skip_whitespace(buffer);
-        if (strlen(testname) == 0)
+        start = skip_whitespace(buffer);
+        if (strlen(start) == 0)
             continue;
-        if (testname[0] == '#')
+        if (start[0] == '#')
             continue;
 
         /* Allocate the new testset structure. */
         if (current == NULL)
             current = listhead;
         else {
-            current->next = xcalloc(1, sizeof(struct testlist));
+            current->next = xcalloc(1, struct testlist);
             current = current->next;
         }
-        current->ts = xcalloc(1, sizeof(struct testset));
+        current->ts = xcalloc(1, struct testset);
         current->ts->plan = PLAN_INIT;
-        current->ts->file = xstrdup(testname);
+
+        /* Parse the line and store the results in the testset struct. */
+        parse_test_list_line(start, current->ts, source, build);
     }
     fclose(file);
 
@@ -1276,13 +1448,13 @@ read_test_list(const char *filename)
  * freeing.
  */
 static struct testlist *
-build_test_list(char *argv[], int argc)
+build_test_list(char *argv[], int argc, const char *source, const char *build)
 {
     int i;
     struct testlist *listhead, *current;
 
     /* Create the initial container list that will hold our results. */
-    listhead = xcalloc(1, sizeof(struct testlist));
+    listhead = xcalloc(1, struct testlist);
     current = NULL;
 
     /* Walk the list of arguments and create test sets for them. */
@@ -1290,12 +1462,15 @@ build_test_list(char *argv[], int argc)
         if (current == NULL)
             current = listhead;
         else {
-            current->next = xcalloc(1, sizeof(struct testlist));
+            current->next = xcalloc(1, struct testlist);
             current = current->next;
         }
-        current->ts = xcalloc(1, sizeof(struct testset));
+        current->ts = xcalloc(1, struct testset);
         current->ts->plan = PLAN_INIT;
         current->ts->file = xstrdup(argv[i]);
+        current->ts->command = xcalloc(2, char *);
+        current->ts->command[0] = find_test(current->ts->file, source, build);
+        current->ts->command[1] = NULL;
     }
 
     /* If there were no tests, current is still NULL. */
@@ -1313,8 +1488,12 @@ build_test_list(char *argv[], int argc)
 static void
 free_testset(struct testset *ts)
 {
+    size_t i;
+
     free(ts->file);
-    free(ts->path);
+    for (i = 0; ts->command[i] != NULL; i++)
+        free(ts->command[i]);
+    free(ts->command);
     free(ts->results);
     free(ts->reason);
     free(ts);
@@ -1329,8 +1508,7 @@ free_testset(struct testset *ts)
  * frees the test list that's passed in.
  */
 static int
-test_batch(struct testlist *tests, const char *source, const char *build,
-           enum test_verbose verbose)
+test_batch(struct testlist *tests, enum test_verbose verbose)
 {
     size_t length, i;
     size_t longest = 0;
@@ -1381,7 +1559,6 @@ test_batch(struct testlist *tests, const char *source, const char *build,
             fflush(stdout);
 
         /* Run the test. */
-        ts->path = find_test(ts->file, source, build);
         succeeded = test_run(ts, verbose);
         fflush(stdout);
         if (verbose)
@@ -1398,10 +1575,10 @@ test_batch(struct testlist *tests, const char *source, const char *build,
         /* If the test fails, we shuffle it over to the fail list. */
         if (!succeeded) {
             if (failhead == NULL) {
-                failhead = xmalloc(sizeof(struct testset));
+                failhead = xcalloc(1, struct testlist);
                 failtail = failhead;
             } else {
-                failtail->next = xmalloc(sizeof(struct testset));
+                failtail->next = xcalloc(1, struct testlist);
                 failtail = failtail->next;
             }
             failtail->ts = ts;
@@ -1444,7 +1621,7 @@ test_batch(struct testlist *tests, const char *source, const char *build,
         fputs("All tests successful", stdout);
     else
         printf("Failed %lu/%lu tests, %.2f%% okay", failed, total,
-               (total - failed) * 100.0 / total);
+               (double) (total - failed) * 100.0 / (double) total);
     if (skipped != 0) {
         if (skipped == 1)
             printf(", %lu test skipped", skipped);
@@ -1570,11 +1747,11 @@ main(int argc, char *argv[])
         else
             shortlist++;
         printf(banner, shortlist);
-        tests = read_test_list(list);
-        status = test_batch(tests, source, build, verbose) ? 0 : 1;
+        tests = read_test_list(list, source, build);
+        status = test_batch(tests, verbose) ? 0 : 1;
     } else {
-        tests = build_test_list(argv, argc);
-        status = test_batch(tests, source, build, verbose) ? 0 : 1;
+        tests = build_test_list(argv, argc, source, build);
+        status = test_batch(tests, verbose) ? 0 : 1;
     }
 
     /* For valgrind cleanliness, free all our memory. */
similarity index 81%
rename from tests/docs/urls-t
rename to tests/style/obsolete-strings-t
index cad76d89c738e7eb5bdef53a553189be4ec717b9..02fd30c9bfc98ea014c84b4f4c2ac1c9aa503822 100755 (executable)
@@ -1,15 +1,15 @@
 #!/usr/bin/perl
 #
-# Check URLs in source files.
+# Check for obsolete strings in source files.
 #
-# Examine all source files in a distribution for bad URL patterns and report
-# on files that fail this check.  Currently, this just checks that all the
-# links to www.eyrie.org are https.
+# Examine all source files in a distribution for obsolete strings and report
+# on files that fail this check.  This catches various transitions I want to
+# do globally in all my packages, like changing my personal URLs to https.
 #
 # The canonical version of this file is maintained in the rra-c-util package,
 # which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
 #
-# Copyright 2016 Russ Allbery <eagle@eyrie.org>
+# Copyright 2016, 2018-2019 Russ Allbery <eagle@eyrie.org>
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
 # copy of this software and associated documentation files (the "Software"),
 # 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
 
-use 5.006;
+use 5.008;
 use strict;
 use warnings;
 
 use lib "$ENV{C_TAP_SOURCE}/tap/perl";
 
-use File::Basename qw(basename);
-use Test::More;
 use Test::RRA qw(skip_unless_author);
 use Test::RRA::Automake qw(all_files automake_setup);
 
+use File::Basename qw(basename);
+use Test::More;
+
 # Bad patterns to search for.
 my @BAD_REGEXES = (qr{ http:// \S+ [.]eyrie[.]org }xms);
-my @BAD_STRINGS = qw(rra@stanford.edu);
+my @BAD_STRINGS = qw(rra@stanford.edu RRA_MAINTAINER_TESTS);
+
+# File names to exclude from this check.
+my %EXCLUDE = map { $_ => 1 } qw(NEWS obsolete-strings.t obsolete-strings-t);
 
 # Only run this test for the package author, since it doesn't indicate any
 # user-noticable flaw in the package itself.
-skip_unless_author('Documentation URL tests');
+skip_unless_author('Obsolete strings tests');
 
 # Set up Automake testing.
 automake_setup();
@@ -60,8 +66,8 @@ sub check_file {
     my ($path) = @_;
     my $filename = basename($path);
 
-    # Ignore this check itself (or the Perl version of it) and binary files.
-    return if ($filename eq 'urls.t' || $filename eq 'urls-t');
+    # Ignore excluded and binary files.
+    return if $EXCLUDE{$filename};
     return if !-T $path;
 
     # Scan the file.
index 0c96fce2a8b98c83a923e4058eb1012b70a7e2d5..b5f42d0211a4f8bbb3ce50764e170a9c4bba9959 100644 (file)
@@ -12,9 +12,9 @@
  * This file is part of C TAP Harness.  The current version plus supporting
  * documentation is at <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
  *
- * Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016
- *     Russ Allbery <eagle@eyrie.org>
- * Copyright 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2011, 2012, 2013, 2014
+ * Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2009-2019 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2001-2002, 2004-2008, 2011-2014
  *     The Board of Trustees of the Leland Stanford Junior University
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -34,6 +34,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 <errno.h>
@@ -99,6 +101,8 @@ static int _aborted = 0;
  */
 struct cleanup_func {
     test_cleanup_func func;
+    test_cleanup_func_with_data func_with_data;
+    void *data;
     struct cleanup_func *next;
 };
 static struct cleanup_func *cleanup_funcs = NULL;
@@ -124,16 +128,15 @@ static struct diag_file *diag_files = NULL;
  * print_desc, which has to be done in a macro.  Assumes that format is the
  * argument immediately before the variadic arguments.
  */
-#define PRINT_DESC(prefix, format)    \
-    do {                              \
-        if (format != NULL) {         \
-            va_list args;             \
-            if (prefix != NULL)       \
-                printf("%s", prefix); \
-            va_start(args, format);   \
-            vprintf(format, args);    \
-            va_end(args);             \
-        }                             \
+#define PRINT_DESC(prefix, format)  \
+    do {                            \
+        if (format != NULL) {       \
+            va_list args;           \
+            printf("%s", prefix);   \
+            va_start(args, format); \
+            vprintf(format, args);  \
+            va_end(args);           \
+        }                           \
     } while (0)
 
 
@@ -170,7 +173,7 @@ concat(const char *first, ...)
     length++;
 
     /* Create the string. */
-    result = bmalloc(length);
+    result = bcalloc_type(length, char);
     va_start(args, first);
     offset = 0;
     for (string = first; string != NULL; string = va_arg(args, const char *)) {
@@ -183,6 +186,68 @@ concat(const char *first, ...)
 }
 
 
+/*
+ * Helper function for check_diag_files to handle a single line in a diag
+ * file.
+ *
+ * The general scheme here used is as follows: read one line of output.  If we
+ * get NULL, check for an error.  If there was one, bail out of the test
+ * program; otherwise, return, and the enclosing loop will check for EOF.
+ *
+ * If we get some data, see if it ends in a newline.  If it doesn't end in a
+ * newline, we have one of two cases: our buffer isn't large enough, in which
+ * case we resize it and try again, or we have incomplete data in the file, in
+ * which case we rewind the file and will try again next time.
+ *
+ * Returns a boolean indicating whether the last line was incomplete.
+ */
+static int
+handle_diag_file_line(struct diag_file *file, fpos_t where)
+{
+    int size;
+    size_t length;
+
+    /* Read the next line from the file. */
+    size = file->bufsize > INT_MAX ? INT_MAX : (int) file->bufsize;
+    if (fgets(file->buffer, size, file->file) == NULL) {
+        if (ferror(file->file))
+            sysbail("cannot read from %s", file->name);
+        return 0;
+    }
+
+    /*
+     * See if the line ends in a newline.  If not, see which error case we
+     * have.
+     */
+    length = strlen(file->buffer);
+    if (file->buffer[length - 1] != '\n') {
+        int incomplete = 0;
+
+        /* Check whether we ran out of buffer space and resize if so. */
+        if (length < file->bufsize - 1)
+            incomplete = 1;
+        else {
+            file->bufsize += BUFSIZ;
+            file->buffer =
+                breallocarray_type(file->buffer, file->bufsize, char);
+        }
+
+        /*
+         * On either incomplete lines or too small of a buffer, rewind
+         * and read the file again (on the next pass, if incomplete).
+         * It's simpler than trying to double-buffer the file.
+         */
+        if (fsetpos(file->file, &where) < 0)
+            sysbail("cannot set position in %s", file->name);
+        return incomplete;
+    }
+
+    /* We saw a complete line.  Print it out. */
+    printf("# %s", file->buffer);
+    return 0;
+}
+
+
 /*
  * Check all registered diag_files for any output.  We only print out the
  * output if we see a complete line; otherwise, we wait for the next newline.
@@ -192,20 +257,10 @@ check_diag_files(void)
 {
     struct diag_file *file;
     fpos_t where;
-    size_t length;
-    int size, incomplete;
+    int incomplete;
 
     /*
-     * Walk through each file and read each line of output available.  The
-     * general scheme here used is as follows: try to read a line of output at
-     * a time.  If we get NULL, check for EOF; on EOF, advance to the next
-     * file.
-     *
-     * If we get some data, see if it ends in a newline.  If it doesn't end in
-     * a newline, we have one of two cases: our buffer isn't large enough, in
-     * which case we resize it and try again, or we have incomplete data in
-     * the file, in which case we rewind the file and will try again next
-     * time.
+     * Walk through each file and read each line of output available.
      */
     for (file = diag_files; file != NULL; file = file->next) {
         clearerr(file->file);
@@ -217,41 +272,7 @@ check_diag_files(void)
         /* Continue until we get EOF or an incomplete line of data. */
         incomplete = 0;
         while (!feof(file->file) && !incomplete) {
-            size = file->bufsize > INT_MAX ? INT_MAX : (int) file->bufsize;
-            if (fgets(file->buffer, size, file->file) == NULL) {
-                if (ferror(file->file))
-                    sysbail("cannot read from %s", file->name);
-                continue;
-            }
-
-            /*
-             * See if the line ends in a newline.  If not, see which error
-             * case we have.  Use UINT_MAX as a substitute for SIZE_MAX (see
-             * the comment for breallocarray).
-             */
-            length = strlen(file->buffer);
-            if (file->buffer[length - 1] != '\n') {
-                if (length < file->bufsize - 1)
-                    incomplete = 1;
-                else {
-                    if (file->bufsize >= UINT_MAX - BUFSIZ)
-                        sysbail("line too long in %s", file->name);
-                    file->bufsize += BUFSIZ;
-                    file->buffer = brealloc(file->buffer, file->bufsize);
-                }
-
-                /*
-                 * On either incomplete lines or too small of a buffer, rewind
-                 * and read the file again (on the next pass, if incomplete).
-                 * It's simpler than trying to double-buffer the file.
-                 */
-                if (fsetpos(file->file, &where) < 0)
-                    sysbail("cannot set position in %s", file->name);
-                continue;
-            }
-
-            /* We saw a complete line.  Print it out. */
-            printf("# %s", file->buffer);
+            incomplete = handle_diag_file_line(file, where);
         }
     }
 }
@@ -304,7 +325,13 @@ finish(void)
      */
     primary = (_process == 0 || getpid() == _process);
     while (cleanup_funcs != NULL) {
-        cleanup_funcs->func(success, primary);
+        if (cleanup_funcs->func_with_data) {
+            void *data = cleanup_funcs->data;
+
+            cleanup_funcs->func_with_data(success, primary, data);
+        } else {
+            cleanup_funcs->func(success, primary);
+        }
         current = cleanup_funcs;
         cleanup_funcs = cleanup_funcs->next;
         free(current);
@@ -489,22 +516,81 @@ skip_block(unsigned long count, const char *reason, ...)
 
 
 /*
- * Takes an expected integer and a seen integer and assumes the test passes
- * if those two numbers match.
+ * Takes two boolean values and requires the truth value of both match.
+ */
+int
+is_bool(int left, int right, const char *format, ...)
+{
+    int success;
+
+    fflush(stderr);
+    check_diag_files();
+    success = (!!left == !!right);
+    if (success)
+        printf("ok %lu", testnum++);
+    else {
+        diag(" left: %s", !!left ? "true" : "false");
+        diag("right: %s", !!right ? "true" : "false");
+        printf("not ok %lu", testnum++);
+        _failed++;
+    }
+    PRINT_DESC(" - ", format);
+    putchar('\n');
+    return success;
+}
+
+
+/*
+ * Takes two integer values and requires they match.
+ */
+int
+is_int(long left, long right, const char *format, ...)
+{
+    int success;
+
+    fflush(stderr);
+    check_diag_files();
+    success = (left == right);
+    if (success)
+        printf("ok %lu", testnum++);
+    else {
+        diag(" left: %ld", left);
+        diag("right: %ld", right);
+        printf("not ok %lu", testnum++);
+        _failed++;
+    }
+    PRINT_DESC(" - ", format);
+    putchar('\n');
+    return success;
+}
+
+
+/*
+ * Takes two strings and requires they match (using strcmp).  NULL arguments
+ * are permitted and handled correctly.
  */
 int
-is_int(long wanted, long seen, const char *format, ...)
+is_string(const char *left, const char *right, const char *format, ...)
 {
     int success;
 
     fflush(stderr);
     check_diag_files();
-    success = (wanted == seen);
+
+    /* Compare the strings, being careful of NULL. */
+    if (left == NULL)
+        success = (right == NULL);
+    else if (right == NULL)
+        success = 0;
+    else
+        success = (strcmp(left, right) == 0);
+
+    /* Report the results. */
     if (success)
         printf("ok %lu", testnum++);
     else {
-        diag("wanted: %ld", wanted);
-        diag("  seen: %ld", seen);
+        diag(" left: %s", left == NULL ? "(null)" : left);
+        diag("right: %s", right == NULL ? "(null)" : right);
         printf("not ok %lu", testnum++);
         _failed++;
     }
@@ -515,26 +601,22 @@ is_int(long wanted, long seen, const char *format, ...)
 
 
 /*
- * Takes a string and what the string should be, and assumes the test passes
- * if those strings match (using strcmp).
+ * Takes two unsigned longs and requires they match.  On failure, reports them
+ * in hex.
  */
 int
-is_string(const char *wanted, const char *seen, const char *format, ...)
+is_hex(unsigned long left, unsigned long right, const char *format, ...)
 {
     int success;
 
-    if (wanted == NULL)
-        wanted = "(null)";
-    if (seen == NULL)
-        seen = "(null)";
     fflush(stderr);
     check_diag_files();
-    success = (strcmp(wanted, seen) == 0);
+    success = (left == right);
     if (success)
         printf("ok %lu", testnum++);
     else {
-        diag("wanted: %s", wanted);
-        diag("  seen: %s", seen);
+        diag(" left: %lx", (unsigned long) left);
+        diag("right: %lx", (unsigned long) right);
         printf("not ok %lu", testnum++);
         _failed++;
     }
@@ -545,22 +627,30 @@ is_string(const char *wanted, const char *seen, const char *format, ...)
 
 
 /*
- * Takes an expected unsigned long and a seen unsigned long and assumes the
- * test passes if the two numbers match.  Otherwise, reports them in hex.
+ * Takes pointers to a regions of memory and requires that len bytes from each
+ * match.  Otherwise reports any bytes which didn't match.
  */
 int
-is_hex(unsigned long wanted, unsigned long seen, const char *format, ...)
+is_blob(const void *left, const void *right, size_t len, const char *format,
+        ...)
 {
     int success;
+    size_t i;
 
     fflush(stderr);
     check_diag_files();
-    success = (wanted == seen);
+    success = (memcmp(left, right, len) == 0);
     if (success)
         printf("ok %lu", testnum++);
     else {
-        diag("wanted: %lx", (unsigned long) wanted);
-        diag("  seen: %lx", (unsigned long) seen);
+        const unsigned char *left_c = (const unsigned char *) left;
+        const unsigned char *right_c = (const unsigned char *) right;
+
+        for (i = 0; i < len; i++) {
+            if (left_c[i] != right_c[i])
+                diag("offset %lu: left %02x, right %02x", (unsigned long) i,
+                     left_c[i], right_c[i]);
+        }
         printf("not ok %lu", testnum++);
         _failed++;
     }
@@ -664,12 +754,12 @@ diag_file_add(const char *name)
 {
     struct diag_file *file, *prev;
 
-    file = bcalloc(1, sizeof(struct diag_file));
+    file = bcalloc_type(1, struct diag_file);
     file->name = bstrdup(name);
     file->file = fopen(file->name, "r");
     if (file->file == NULL)
         sysbail("cannot open %s", name);
-    file->buffer = bmalloc(BUFSIZ);
+    file->buffer = bcalloc_type(BUFSIZ, char);
     file->bufsize = BUFSIZ;
     if (diag_files == NULL)
         diag_files = file;
@@ -769,6 +859,8 @@ breallocarray(void *p, size_t n, size_t size)
 {
     if (n > 0 && UINT_MAX / n <= size)
         bail("reallocarray too large");
+    if (n == 0)
+        n = 1;
     p = realloc(p, n * size);
     if (p == NULL)
         sysbail("failed to realloc %lu bytes", (unsigned long) (n * size));
@@ -786,7 +878,7 @@ bstrdup(const char *s)
     size_t len;
 
     len = strlen(s) + 1;
-    p = malloc(len);
+    p = (char *) malloc(len);
     if (p == NULL)
         sysbail("failed to strdup %lu bytes", (unsigned long) len);
     memcpy(p, s, len);
@@ -810,8 +902,8 @@ bstrndup(const char *s, size_t n)
     for (p = s; (size_t)(p - s) < n && *p != '\0'; p++)
         ;
     length = (size_t)(p - s);
-    copy = malloc(length + 1);
-    if (p == NULL)
+    copy = (char *) malloc(length + 1);
+    if (copy == NULL)
         sysbail("failed to strndup %lu bytes", (unsigned long) length);
     memcpy(copy, s, length);
     copy[length] = '\0';
@@ -899,21 +991,39 @@ test_tmpdir_free(char *path)
     free(path);
 }
 
-
-/*
- * Register a cleanup function that is called when testing ends.  All such
- * registered functions will be run by finish.
- */
-void
-test_cleanup_register(test_cleanup_func func)
+static void
+register_cleanup(test_cleanup_func func,
+                 test_cleanup_func_with_data func_with_data, void *data)
 {
     struct cleanup_func *cleanup, **last;
 
-    cleanup = bmalloc(sizeof(struct cleanup_func));
+    cleanup = bcalloc_type(1, struct cleanup_func);
     cleanup->func = func;
+    cleanup->func_with_data = func_with_data;
+    cleanup->data = data;
     cleanup->next = NULL;
     last = &cleanup_funcs;
     while (*last != NULL)
         last = &(*last)->next;
     *last = cleanup;
 }
+
+/*
+ * Register a cleanup function that is called when testing ends.  All such
+ * registered functions will be run by finish.
+ */
+void
+test_cleanup_register(test_cleanup_func func)
+{
+    register_cleanup(func, NULL, NULL);
+}
+
+/*
+ * Same as above, but also allows an opaque pointer to be passed to the cleanup
+ * function.
+ */
+void
+test_cleanup_register_with_data(test_cleanup_func_with_data func, void *data)
+{
+    register_cleanup(NULL, func, data);
+}
index 78c04d05424203ae7e297314059cac1549ee72e1..45f15f2892a72e6843b96b8e133f3baf94b41af8 100644 (file)
@@ -4,9 +4,9 @@
  * This file is part of C TAP Harness.  The current version plus supporting
  * documentation is at <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
  *
- * Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016
- *     Russ Allbery <eagle@eyrie.org>
- * Copyright 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2011, 2012, 2014
+ * Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2009-2019 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2001-2002, 2004-2008, 2011-2012, 2014
  *     The Board of Trustees of the Leland Stanford Junior University
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -26,6 +26,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
  */
 
 #ifndef TAP_BASIC_H
@@ -87,15 +89,21 @@ void skip_block(unsigned long count, const char *reason, ...)
     __attribute__((__format__(printf, 2, 3)));
 
 /*
- * Check an expected value against a seen value.  Returns true if the test
- * passes and false if it fails.
+ * Compare two values.  Returns true if the test passes and false if it fails.
+ * is_bool takes an int since the bool type isn't fully portable yet, but
+ * interprets both arguments for their truth value, not for their numeric
+ * value.
  */
-int is_int(long wanted, long seen, const char *format, ...)
+int is_bool(int, int, const char *format, ...)
+    __attribute__((__format__(printf, 3, 4)));
+int is_int(long, long, const char *format, ...)
     __attribute__((__format__(printf, 3, 4)));
-int is_string(const char *wanted, const char *seen, const char *format, ...)
+int is_string(const char *, const char *, const char *format, ...)
     __attribute__((__format__(printf, 3, 4)));
-int is_hex(unsigned long wanted, unsigned long seen, const char *format, ...)
+int is_hex(unsigned long, unsigned long, const char *format, ...)
     __attribute__((__format__(printf, 3, 4)));
+int is_blob(const void *, const void *, size_t, const char *format, ...)
+    __attribute__((__format__(printf, 4, 5)));
 
 /* Bail out with an error.  sysbail appends strerror(errno). */
 void bail(const char *format, ...)
@@ -133,6 +141,14 @@ char *bstrdup(const char *)
 char *bstrndup(const char *, size_t)
     __attribute__((__malloc__, __nonnull__, __warn_unused_result__));
 
+/*
+ * Macros that cast the return value from b* memory functions, making them
+ * usable in C++ code and providing some additional type safety.
+ */
+#define bcalloc_type(n, type) ((type *) bcalloc((n), sizeof(type)))
+#define breallocarray_type(p, n, type) \
+    ((type *) breallocarray((p), (n), sizeof(type)))
+
 /*
  * Find a test file under C_TAP_BUILD or C_TAP_SOURCE, returning the full
  * path.  The returned path should be freed with test_file_path_free().
@@ -156,10 +172,20 @@ void test_tmpdir_free(char *path);
  * The function must return void and will be passed two arguments: an int that
  * will be true if the test completed successfully and false otherwise, and an
  * int that will be true if the cleanup function is run in the primary process
- * (the one that called plan or plan_lazy) and false otherwise.
+ * (the one that called plan or plan_lazy) and false otherwise.  If
+ * test_cleanup_register_with_data is used instead, a generic pointer can be
+ * provided and will be passed to the cleanup function as a third argument.
+ *
+ * test_cleanup_register_with_data is the better API and should have been the
+ * only API.  test_cleanup_register was an API error preserved for backward
+ * cmpatibility.
  */
 typedef void (*test_cleanup_func)(int, int);
+typedef void (*test_cleanup_func_with_data)(int, int, void *);
+
 void test_cleanup_register(test_cleanup_func) __attribute__((__nonnull__));
+void test_cleanup_register_with_data(test_cleanup_func_with_data, void *)
+    __attribute__((__nonnull__));
 
 END_DECLS
 
index 898561359732a9b8b34a5c73801767962d7115bb..765d80290a64082b8bd38373b608545b705e9932 100644 (file)
@@ -15,7 +15,8 @@
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2006, 2007, 2009, 2010, 2011, 2012, 2013, 2014
+ * Copyright 2017 Russ Allbery <eagle@eyrie.org>
+ * 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 <config.h>
@@ -360,7 +363,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')
@@ -456,17 +459,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);
@@ -478,17 +483,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);
@@ -523,14 +530,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;
index dac4ff9669abd37e73aa2592f770da5aca2caabf..066490509df2c9db0bfbd36ce6852cb13dab1f26 100644 (file)
@@ -5,7 +5,8 @@
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2006, 2007, 2009, 2011, 2012, 2013, 2014
+ * Copyright 2017, 2020 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2006-2007, 2009, 2011-2014
  *     The Board of Trustees of the Leland Stanford Junior University
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -25,6 +26,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
  */
 
 #ifndef TAP_KERBEROS_H
@@ -56,11 +59,13 @@ struct kerberos_config {
  * tests require both keytab and password, but PKINIT is not required.
  */
 enum kerberos_needs {
-    TAP_KRB_NEEDS_NONE = 0x00,
-    TAP_KRB_NEEDS_KEYTAB = 0x01,
+    /* clang-format off */
+    TAP_KRB_NEEDS_NONE     = 0x00,
+    TAP_KRB_NEEDS_KEYTAB   = 0x01,
     TAP_KRB_NEEDS_PASSWORD = 0x02,
-    TAP_KRB_NEEDS_BOTH = 0x01 | 0x02,
-    TAP_KRB_NEEDS_PKINIT = 0x04
+    TAP_KRB_NEEDS_BOTH     = 0x01 | 0x02,
+    TAP_KRB_NEEDS_PKINIT   = 0x04
+    /* clang-format on */
 };
 
 BEGIN_DECLS
@@ -103,15 +108,15 @@ void kerberos_cleanup(void);
 void kerberos_generate_conf(const char *realm);
 void kerberos_cleanup_conf(void);
 
-/* Thes interfaces are only available with native Kerberos support. */
+/* These interfaces are only available with native Kerberos support. */
 #ifdef HAVE_KRB5
 
 /* Bail out with an error, appending the Kerberos error message. */
-void bail_krb5(krb5_context, krb5_error_code, const char *format, ...)
+void bail_krb5(krb5_context, long, const char *format, ...)
     __attribute__((__noreturn__, __nonnull__(3), __format__(printf, 3, 4)));
 
 /* Report a diagnostic with Kerberos error to stderr prefixed with #. */
-void diag_krb5(krb5_context, krb5_error_code, const char *format, ...)
+void diag_krb5(krb5_context, long, const char *format, ...)
     __attribute__((__nonnull__(3), __format__(printf, 3, 4)));
 
 /*
index a7aee0fef31293cb1695de32c83e72be0b6185b6..1827a689e380ee9af32e4c51407c98af1d97f334 100644 (file)
@@ -10,8 +10,8 @@
 # <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
 #
 # Written by Russ Allbery <eagle@eyrie.org>
-# Copyright 2009, 2010, 2011, 2012, 2016 Russ Allbery <eagle@eyrie.org>
-# Copyright 2006, 2007, 2008, 2013
+# Copyright 2009-2012, 2016 Russ Allbery <eagle@eyrie.org>
+# Copyright 2006-2008, 2013
 #     The Board of Trustees of the Leland Stanford Junior University
 #
 # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -31,6 +31,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
 
 # Print out the number of test cases we expect to run.
 plan () {
index faf57a193f6885254056aa18b0341e7172fcdfc1..c2c8b5c7315ddf43ca9e99532c0f61d0f95d25ef 100644 (file)
@@ -8,7 +8,7 @@
  * This file is part of C TAP Harness.  The current version plus supporting
  * documentation is at <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
  *
- * Copyright 2008, 20122013, 2015 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2008, 2012-2013, 2015 Russ Allbery <eagle@eyrie.org>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -27,6 +27,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
  */
 
 #ifndef TAP_MACROS_H
index bcd653240f4676ae102f4694385450db00dc81bf..cd106d03e272cbcfb59eae8550e21489347d7715 100644 (file)
@@ -5,28 +5,46 @@
 # by both C packages with Automake and by stand-alone Perl modules.  See
 # Test::RRA::Automake for additional functions specifically for C Automake
 # distributions.
+#
+# SPDX-License-Identifier: MIT
 
 package Test::RRA;
 
-use 5.006;
+use 5.008;
+use base qw(Exporter);
 use strict;
 use warnings;
 
-use Exporter;
+use Carp qw(croak);
 use File::Temp;
-use Test::More;
 
-# For Perl 5.006 compatibility.
-## no critic (ClassHierarchies::ProhibitExplicitISA)
+# Abort if Test::More was loaded before Test::RRA to be sure that we get the
+# benefits of the Test::More probing below.
+if ($INC{'Test/More.pm'}) {
+    croak('Test::More loaded before Test::RRA');
+}
+
+# Red Hat's base perl package doesn't include Test::More (one has to install
+# the perl-core package in addition).  Try to detect this and skip any Perl
+# tests if Test::More is not present.  This relies on Test::RRA being included
+# before Test::More.
+eval {
+    require Test::More;
+    Test::More->import();
+};
+if ($@) {
+    print "1..0 # SKIP Test::More required for test\n"
+      or croak('Cannot write to stdout');
+    exit 0;
+}
 
 # Declare variables that should be set in BEGIN for robustness.
-our (@EXPORT_OK, @ISA, $VERSION);
+our (@EXPORT_OK, $VERSION);
 
 # Set $VERSION and everything export-related in a BEGIN block for robustness
 # against circular module loading (not that we load any modules, but
 # consistency is good).
 BEGIN {
-    @ISA       = qw(Exporter);
     @EXPORT_OK = qw(
       is_file_contents skip_unless_author skip_unless_automated use_prereq
     );
@@ -34,7 +52,7 @@ BEGIN {
     # This version should match the corresponding rra-c-util release, but with
     # two digits for the minor version, including a leading zero if necessary,
     # so that it will sort properly.
-    $VERSION = '6.02';
+    $VERSION = '8.02';
 }
 
 # Compare a string to the contents of a file, similar to the standard is()
@@ -59,22 +77,27 @@ sub is_file_contents {
         return;
     }
 
-    # Otherwise, we show a diff, but only if we have IPC::System::Simple.
-    eval { require IPC::System::Simple };
+    # Otherwise, we show a diff, but only if we have IPC::System::Simple and
+    # diff succeeds.  Otherwise, we fall back on showing the full expected and
+    # seen output.
+    eval {
+        require IPC::System::Simple;
+
+        my $tmp     = File::Temp->new();
+        my $tmpname = $tmp->filename;
+        print {$tmp} $got or BAIL_OUT("Cannot write to $tmpname: $!\n");
+        my @command = ('diff', '-u', $expected, $tmpname);
+        my $diff    = IPC::System::Simple::capturex([0 .. 1], @command);
+        diag($diff);
+    };
     if ($@) {
-        ok(0, $message);
-        return;
+        diag('Expected:');
+        diag($expected);
+        diag('Seen:');
+        diag($data);
     }
 
-    # They're not equal.  Write out what we got so that we can run diff.
-    my $tmp     = File::Temp->new();
-    my $tmpname = $tmp->filename;
-    print {$tmp} $got or BAIL_OUT("Cannot write to $tmpname: $!\n");
-    my @command = ('diff', '-u', $expected, $tmpname);
-    my $diff = IPC::System::Simple::capturex([0 .. 1], @command);
-    diag($diff);
-
-    # Remove the temporary file and report failure.
+    # Report failure.
     ok(0, $message);
     return;
 }
@@ -89,7 +112,7 @@ sub is_file_contents {
 sub skip_unless_author {
     my ($description) = @_;
     if (!$ENV{AUTHOR_TESTING}) {
-        plan skip_all => "$description only run for author";
+        plan(skip_all => "$description only run for author");
     }
     return;
 }
@@ -108,7 +131,7 @@ sub skip_unless_automated {
     for my $env (qw(AUTOMATED_TESTING RELEASE_TESTING AUTHOR_TESTING)) {
         return if $ENV{$env};
     }
-    plan skip_all => "$description normally skipped";
+    plan(skip_all => "$description normally skipped");
     return;
 }
 
@@ -150,14 +173,14 @@ sub use_prereq {
             use $module $version \@imports;
             1;
         };
-        $error = $@;
+        $error  = $@;
         $sigdie = $SIG{__DIE__} || undef;
     }
 
     # If the use failed for any reason, skip the test.
     if (!$result || $error) {
         my $name = length($version) > 0 ? "$module $version" : $module;
-        plan skip_all => "$name required for test";
+        plan(skip_all => "$name required for test");
     }
 
     # If the module set $SIG{__DIE__}, we cleared that via local.  Restore it.
@@ -200,6 +223,14 @@ This module collects utility functions that are useful for Perl test scripts.
 It assumes Russ Allbery's Perl module layout and test conventions and will
 only be useful for other people if they use the same conventions.
 
+This module B<must> be loaded before Test::More or it will abort during
+import.  It will skip the test (by printing a skip message to standard output
+and exiting with status 0, equivalent to C<plan skip_all>) during import if
+Test::More is not available.  This allows tests written in Perl using this
+module to be skipped if run on a system with Perl but not Test::More, such as
+Red Hat systems with the C<perl> package but not the C<perl-core> package
+installed.
+
 =head1 FUNCTIONS
 
 None of these functions are imported by default.  The ones used by a script
@@ -244,7 +275,9 @@ Russ Allbery <eagle@eyrie.org>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2013, 2014 The Board of Trustees of the Leland Stanford Junior
+Copyright 2016, 2018-2019 Russ Allbery <eagle@eyrie.org>
+
+Copyright 2013-2014 The Board of Trustees of the Leland Stanford Junior
 University
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -277,3 +310,7 @@ by the L<Lancaster
 Consensus|https://github.com/Perl-Toolchain-Gang/toolchain-site/blob/master/lancaster-consensus.md>.
 
 =cut
+
+# Local Variables:
+# copyright-at-end-flag: t
+# End:
index 429666790eda6e148a5ff0970da7ca780a7cfc10..16c9b0153dbe502970196d1e7ef46aee5a23de94 100644 (file)
 # All the functions here assume that C_TAP_BUILD and C_TAP_SOURCE are set in
 # the environment.  This is normally done via the C TAP Harness runtests
 # wrapper.
+#
+# SPDX-License-Identifier: MIT
 
 package Test::RRA::Automake;
 
-use 5.006;
+use 5.008;
+use base qw(Exporter);
 use strict;
 use warnings;
 
-# For Perl 5.006 compatibility.
-## no critic (ClassHierarchies::ProhibitExplicitISA)
-
 use Exporter;
 use File::Find qw(find);
 use File::Spec;
@@ -52,13 +52,12 @@ use lib $PERL_BLIB_ARCH;
 use lib $PERL_BLIB_LIB;
 
 # Declare variables that should be set in BEGIN for robustness.
-our (@EXPORT_OK, @ISA, $VERSION);
+our (@EXPORT_OK, $VERSION);
 
 # Set $VERSION and everything export-related in a BEGIN block for robustness
 # against circular module loading (not that we load any modules, but
 # consistency is good).
 BEGIN {
-    @ISA       = qw(Exporter);
     @EXPORT_OK = qw(
       all_files automake_setup perl_dirs test_file_path test_tmpdir
     );
@@ -66,17 +65,22 @@ BEGIN {
     # This version should match the corresponding rra-c-util release, but with
     # two digits for the minor version, including a leading zero if necessary,
     # so that it will sort properly.
-    $VERSION = '6.02';
+    $VERSION = '8.02';
 }
 
 # Directories to skip globally when looking for all files, or for directories
 # that could contain Perl files.
-my @GLOBAL_SKIP = qw(.git _build autom4te.cache build-aux);
+my @GLOBAL_SKIP = qw(
+  .git .pc _build autom4te.cache build-aux perl/_build perl/blib
+);
 
 # Additional paths to skip when building a list of all files in the
 # distribution.  This primarily skips build artifacts that aren't interesting
 # to any of the tests.  These match any path component.
-my @FILES_SKIP = qw(.deps .dirstamp .libs config.h.in~ configure);
+my @FILES_SKIP = qw(
+  .deps .dirstamp .libs aclocal.m4 config.h config.h.in config.h.in~ config.log
+  config.status configure
+);
 
 # The temporary directory created by test_tmpdir, if any.  If this is set,
 # attempt to remove the directory stored here on program exit (but ignore
@@ -99,7 +103,7 @@ sub all_files {
         my $file = $_;
         my $path = $File::Find::name;
         $path =~ s{ \A [.]/ }{}xms;
-        if ($skip{$path} or $files_skip{$file} or $file =~ m{ [.] lo \z }xms) {
+        if ($skip{$path} || $files_skip{$file} || $file =~ m{ [.] lo \z }xms) {
             $File::Find::prune = 1;
             return;
         }
@@ -182,7 +186,7 @@ sub automake_setup {
         @builddirs = File::Spec->splitdir($builddirs);
         pop(@builddirs);
         my $libdir = File::Spec->catdir(@builddirs, $LIBRARY_PATH);
-        my $path = File::Spec->catpath($buildvol, $libdir, q{});
+        my $path   = File::Spec->catpath($buildvol, $libdir, q{});
         if (-d "$path/.libs") {
             $path .= '/.libs';
         }
@@ -222,7 +226,7 @@ sub perl_dirs {
     }
 
     # Convert the skip lists into hashes for convenience.
-    my %skip = map { $_ => 1 } @skip, 'tests';
+    my %skip       = map { $_ => 1 } @skip, 'tests';
     my %skip_tests = map { $_ => 1 } @skip_tests;
 
     # Build the list of top-level directories to test.
@@ -444,7 +448,7 @@ Russ Allbery <eagle@eyrie.org>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2014, 2015 Russ Allbery <eagle@eyrie.org>
+Copyright 2014-2015, 2018-2020 Russ Allbery <eagle@eyrie.org>
 
 Copyright 2013 The Board of Trustees of the Leland Stanford Junior University
 
@@ -477,3 +481,7 @@ The C TAP Harness test driver and libraries for TAP-based C testing are
 available from L<https://www.eyrie.org/~eagle/software/c-tap-harness/>.
 
 =cut
+
+# Local Variables:
+# copyright-at-end-flag: t
+# End:
index bdb31e60c0f31513c49730ec9ee58834c40cc49d..70641405c6cd15352a5057e56a2d066ce9b97960 100644 (file)
@@ -4,27 +4,25 @@
 # configuration file to store some package-specific data.  This module loads
 # that configuration and provides the namespace for the configuration
 # settings.
+#
+# SPDX-License-Identifier: MIT
 
 package Test::RRA::Config;
 
-use 5.006;
+use 5.008;
+use base qw(Exporter);
 use strict;
 use warnings;
 
-# For Perl 5.006 compatibility.
-## no critic (ClassHierarchies::ProhibitExplicitISA)
-
-use Exporter;
 use Test::More;
 
 # Declare variables that should be set in BEGIN for robustness.
-our (@EXPORT_OK, @ISA, $VERSION);
+our (@EXPORT_OK, $VERSION);
 
 # Set $VERSION and everything export-related in a BEGIN block for robustness
 # against circular module loading (not that we load any modules, but
 # consistency is good).
 BEGIN {
-    @ISA       = qw(Exporter);
     @EXPORT_OK = qw(
       $COVERAGE_LEVEL @COVERAGE_SKIP_TESTS @CRITIC_IGNORE $LIBRARY_PATH
       $MINIMUM_VERSION %MINIMUM_VERSION @MODULE_VERSION_IGNORE
@@ -34,7 +32,7 @@ BEGIN {
     # This version should match the corresponding rra-c-util release, but with
     # two digits for the minor version, including a leading zero if necessary,
     # so that it will sort properly.
-    $VERSION = '6.02';
+    $VERSION = '8.02';
 }
 
 # If C_TAP_BUILD or C_TAP_SOURCE are set in the environment, look for
@@ -185,9 +183,9 @@ Russ Allbery <eagle@eyrie.org>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2015, 2016 Russ Allbery <eagle@eyrie.org>
+Copyright 2015-2016, 2019 Russ Allbery <eagle@eyrie.org>
 
-Copyright 20132014 The Board of Trustees of the Leland Stanford Junior
+Copyright 2013-2014 The Board of Trustees of the Leland Stanford Junior
 University
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -220,3 +218,7 @@ The C TAP Harness test driver and libraries for TAP-based C testing are
 available from L<https://www.eyrie.org/~eagle/software/c-tap-harness/>.
 
 =cut
+
+# Local Variables:
+# copyright-at-end-flag: t
+# End:
index 4211042758c1328dcc6e2ad1be2f00e9925d6fde..2f797f8f756728531124a4636c0301d4f9178a11 100644 (file)
@@ -14,8 +14,8 @@
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2002, 2004, 2005, 2013, 2016 Russ Allbery <eagle@eyrie.org>
- * Copyright 2009, 2010, 2011, 2013, 2014
+ * Copyright 2002, 2004-2005, 2013, 2016-2017 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2009-2011, 2013-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 +35,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 <config.h>
@@ -366,7 +368,7 @@ process_stop_all(int success UNUSED, int primary)
  * Read the PID of a process from a file.  This is necessary when running
  * under fakeroot to get the actual PID of the remctld process.
  */
-static long
+static pid_t
 read_pidfile(const char *path)
 {
     FILE *file;
@@ -382,7 +384,7 @@ read_pidfile(const char *path)
     pid = strtol(buffer, NULL, 10);
     if (pid <= 0)
         bail("cannot read PID from %s", path);
-    return pid;
+    return (pid_t) pid;
 }
 
 
index b2637a039abc8871d2ece989685bf2e4b2b6363c..4210c209ed0b3e849c99cd9d056993921f016483 100644 (file)
@@ -5,7 +5,7 @@
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 20092010, 2013
+ * Copyright 2009-2010, 2013
  *     The Board of Trustees of the Leland Stanford Junior University
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -25,6 +25,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
  */
 
 #ifndef TAP_PROCESS_H
index 56450294ddebdcd33813fd2a5b94e77ec9104aba..71cf571e6f03b0389ceff3799bc72d56ba71d4ce 100644 (file)
@@ -7,7 +7,7 @@
  * The canonical version of this file is maintained in the rra-c-util package,
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
- * Copyright 20112012 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2011-2012 Russ Allbery <eagle@eyrie.org>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -26,6 +26,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 <config.h>
index cb4c7911dc2a1d10481e6a00ce5f76681a167e3a..651c38a26f0639360d52ddf8693dfe6ed69fed84 100644 (file)
@@ -7,7 +7,7 @@
  * The canonical version of this file is maintained in the rra-c-util package,
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
- * Copyright 20112012 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2011-2012 Russ Allbery <eagle@eyrie.org>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -26,6 +26,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
  */
 
 #ifndef TAP_STRING_H
index e00190088dfe2e52fd13f39cb45f01199a23809d..8bb37775a208a641e9c26bcea28fa2ccd92beb7b 100755 (executable)
@@ -3,6 +3,7 @@
 # Test suite for Heimdal per-principal history.
 #
 # Written by Russ Allbery <eagle@eyrie.org>
+# Copyright 2020 Russ Allbery <eagle@eyrie.org>
 # Copyright 2014
 #     The Board of Trustees of the Leland Stanford Junior University
 #
@@ -14,11 +15,12 @@ use warnings;
 
 use lib "$ENV{SOURCE}/tap/perl";
 
-use Fcntl qw(O_CREAT O_RDWR);
-use Test::More;
 use Test::RRA qw(use_prereq);
 use Test::RRA::Automake qw(test_file_path test_tmpdir);
 
+use Fcntl qw(O_CREAT O_RDWR);
+use Test::More;
+
 # Not all of these are used by the test suite, but the rest are required to
 # run the program we're testing, so make sure they can all be loaded.
 use_prereq('DB_File::Lock');
@@ -101,7 +103,7 @@ sub check_password {
     is($status, $test_ref->{status} || 0, "$test_ref->{name} (status)");
     if (defined($test_ref->{error})) {
         is($err, $test_ref->{error}, '...error message');
-        is($out, q{}, '...no output');
+        is($out, q{},                '...no output');
     } else {
         is($err, q{},        '...no errors');
         is($out, 'APPROVED', '...approved');
index bb997a06a7dfa3e610665993231390003dec7f2e..ee0831e7475f006a758ca0d7ea4c386d66e1c5a2 100755 (executable)
@@ -3,7 +3,7 @@
 # Test suite for basic Heimdal external strength checking functionality.
 #
 # Written by Russ Allbery <eagle@eyrie.org>
-# Copyright 2016, 2017 Russ Allbery <eagle@eyrie.org>
+# Copyright 2016, 2017, 2020 Russ Allbery <eagle@eyrie.org>
 # Copyright 2009, 2012, 2013, 2014
 #     The Board of Trustees of the Leland Stanford Junior University
 #
@@ -122,7 +122,7 @@ sub run_heimdal_strength {
     # Run the password strength checker.
     my ($out, $err);
     my $harness = run([$program, $principal], \$in, \$out, \$err);
-    my $status = $? >> 8;
+    my $status  = $? >> 8;
 
     # Return the results.
     return ($status, $out, $err);
@@ -157,7 +157,7 @@ sub check_password {
     is($status, $test_ref->{status} || 0, "$test_ref->{name} (status)");
     if (defined($test_ref->{error})) {
         is($err, $test_ref->{error}, '...error message');
-        is($out, q{}, '...no output');
+        is($out, q{},                '...no output');
     } else {
         is($err, q{},        '...no errors');
         is($out, 'APPROVED', '...approved');
index 73c1719b176643c05580f8b87fb97fc65b86d23c..066d7f81de9e6248e8f1bc9d638a633beb058402 100755 (executable)
@@ -3,6 +3,7 @@
 # Test suite for krb5-strength-wordlist SQLite database generation
 #
 # Written by Russ Allbery <eagle@eyrie.org>
+# Copyright 2020 Russ Allbery <eagle@eyrie.org>
 # Copyright 2014
 #     The Board of Trustees of the Leland Stanford Junior University
 #
@@ -14,10 +15,11 @@ use warnings;
 
 use lib "$ENV{SOURCE}/tap/perl";
 
-use Test::More;
 use Test::RRA qw(use_prereq);
 use Test::RRA::Automake qw(automake_setup test_file_path test_tmpdir);
 
+use Test::More;
+
 # Load prerequisite modules.
 use_prereq('DBI');
 use_prereq('DBD::SQLite');
index 967cfc1e6c6bfc405ed48ec209c9d585f70c0c30..0abae8fe3941d793017a549dbdb2e432874268d5 100755 (executable)
@@ -3,7 +3,7 @@
 # Test suite for krb5-strength-wordlist filtering functions.
 #
 # Written by Russ Allbery <eagle@eyrie.org>
-# Copyright 2016 Russ Allbery <eagle@eyrie.org>
+# Copyright 2016, 2020 Russ Allbery <eagle@eyrie.org>
 # Copyright 2014
 #     The Board of Trustees of the Leland Stanford Junior University
 #
@@ -15,11 +15,12 @@ use warnings;
 
 use lib "$ENV{SOURCE}/tap/perl";
 
-use Encode qw(encode);
-use Test::More;
 use Test::RRA qw(use_prereq);
 use Test::RRA::Automake qw(automake_setup test_file_path test_tmpdir);
 
+use Encode qw(encode);
+use Test::More;
+
 # Load prerequisite modules.
 use_prereq('IPC::Run',     'run');
 use_prereq('Perl6::Slurp', 'slurp');
index 2fc1acb51cec95cdf1538db11543c0c919218f7b..e68c57f7f4e50c2553d5d8ccad1dfa9a6c3362ab 100644 (file)
@@ -5,7 +5,8 @@
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2010, 2011, 2013, 2014
+ * Copyright 2020 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2010-2011, 2013-2014
  *     The Board of Trustees of the Leland Stanford Junior University
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -25,6 +26,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 <config.h>
@@ -56,7 +59,7 @@ main(void)
 /*
  * Test functions.
  */
-static void
+__attribute__((__noreturn__)) static void
 test_warn(void *data UNUSED)
 {
     krb5_context ctx;
@@ -74,7 +77,7 @@ test_warn(void *data UNUSED)
     exit(0);
 }
 
-static void
+__attribute__((__noreturn__)) static void
 test_die(void *data UNUSED)
 {
     krb5_context ctx;
index d27d24e5648aee81a48ccfe526fc47877488d1cc..cfb661ab11da56151b561145f750370cb5daeb28 100644 (file)
@@ -5,8 +5,8 @@
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2002, 2004, 2005, 2015 Russ Allbery <eagle@eyrie.org>
- * Copyright 2009, 2010, 2011, 2012
+ * Copyright 2002, 2004-2005, 2015, 2017, 2020 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2009-2012
  *     The Board of Trustees of the Leland Stanford Junior University
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -26,6 +26,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 <config.h>
@@ -51,35 +53,41 @@ test1(void *data UNUSED)
 {
     warn("warning");
 }
-static void
+
+__attribute__((__noreturn__)) static void
 test2(void *data UNUSED)
 {
     die("fatal");
 }
+
 static void
 test3(void *data UNUSED)
 {
     errno = EPERM;
     syswarn("permissions");
 }
-static void
+
+__attribute__((__noreturn__)) static void
 test4(void *data UNUSED)
 {
     errno = EACCES;
     sysdie("fatal access");
 }
+
 static void
 test5(void *data UNUSED)
 {
     message_program_name = "test5";
     warn("warning");
 }
-static void
+
+__attribute__((__noreturn__)) static void
 test6(void *data UNUSED)
 {
     message_program_name = "test6";
     die("fatal");
 }
+
 static void
 test7(void *data UNUSED)
 {
@@ -87,7 +95,8 @@ test7(void *data UNUSED)
     errno = EPERM;
     syswarn("perms %d", 7);
 }
-static void
+
+__attribute__((__noreturn__)) static void
 test8(void *data UNUSED)
 {
     message_program_name = "test8";
@@ -101,13 +110,14 @@ return10(void)
     return 10;
 }
 
-static void
+__attribute__((__noreturn__)) static void
 test9(void *data UNUSED)
 {
     message_fatal_cleanup = return10;
     die("fatal");
 }
-static void
+
+__attribute__((__noreturn__)) static void
 test10(void *data UNUSED)
 {
     message_program_name = 0;
@@ -115,7 +125,8 @@ test10(void *data UNUSED)
     errno = EPERM;
     sysdie("fatal perm");
 }
-static void
+
+__attribute__((__noreturn__)) static void
 test11(void *data UNUSED)
 {
     message_program_name = "test11";
@@ -125,7 +136,7 @@ test11(void *data UNUSED)
     sysdie("fatal");
 }
 
-static void __attribute__((__format__(printf, 2, 0)))
+__attribute__((__format__(printf, 2, 0))) static void
 log_msg(size_t len, const char *format, va_list args, int error)
 {
     fprintf(stderr, "%lu %d ", (unsigned long) len, error);
@@ -139,12 +150,14 @@ test12(void *data UNUSED)
     message_handlers_warn(1, log_msg);
     warn("warning");
 }
-static void
+
+__attribute__((__noreturn__)) static void
 test13(void *data UNUSED)
 {
     message_handlers_die(1, log_msg);
     die("fatal");
 }
+
 static void
 test14(void *data UNUSED)
 {
@@ -152,7 +165,8 @@ test14(void *data UNUSED)
     errno = EPERM;
     syswarn("warning");
 }
-static void
+
+__attribute__((__noreturn__)) static void
 test15(void *data UNUSED)
 {
     message_handlers_die(2, log_msg, log_msg);
@@ -160,6 +174,7 @@ test15(void *data UNUSED)
     errno = EPERM;
     sysdie("fatal");
 }
+
 static void
 test16(void *data UNUSED)
 {
@@ -168,28 +183,33 @@ test16(void *data UNUSED)
     errno = EPERM;
     syswarn("warning");
 }
+
 static void
 test17(void *data UNUSED)
 {
     notice("notice");
 }
+
 static void
 test18(void *data UNUSED)
 {
     message_program_name = "test18";
     notice("notice");
 }
+
 static void
 test19(void *data UNUSED)
 {
     debug("debug");
 }
+
 static void
 test20(void *data UNUSED)
 {
     message_handlers_notice(1, log_msg);
     notice("foo");
 }
+
 static void
 test21(void *data UNUSED)
 {
@@ -197,18 +217,21 @@ test21(void *data UNUSED)
     message_program_name = "test23";
     debug("baz");
 }
-static void
+
+__attribute__((__noreturn__)) static void
 test22(void *data UNUSED)
 {
     message_handlers_die(0);
     die("hi mom!");
 }
+
 static void
 test23(void *data UNUSED)
 {
     message_handlers_warn(0);
     warn("this is a test");
 }
+
 static void
 test24(void *data UNUSED)
 {
index e8fdd74c2950aa57f7aea787e857f8f7cb71d03c..b3afa31f81fe17a536d16156325071715b990395 100755 (executable)
@@ -6,8 +6,9 @@
 # which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
 #
 # Written by Russ Allbery <eagle@eyrie.org>
-# Copyright 2000, 2001, 2006, 2014, 2016 Russ Allbery <eagle@eyrie.org>
-# Copyright 2008, 2009, 2010, 2012
+# Copyright 2000-2001, 2006, 2014, 2016, 2019-2020
+#     Russ Allbery <eagle@eyrie.org>
+# Copyright 2008-2010, 2012
 #     The Board of Trustees of the Leland Stanford Junior University
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
 # 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
 
 . "$C_TAP_SOURCE/tap/libtap.sh"
 cd "$C_TAP_BUILD/util"
 
-# Run an xmalloc test.  Takes the description, the expectd exit status, the
+# Run an xmalloc test.  Takes the description, the expected exit status, the
 # output, and the arguments.
 ok_xmalloc () {
     local desc w_status w_output output status
@@ -99,46 +102,46 @@ ok_xmalloc "vasprintf large"    0 "" "v" "30000000" "0"
 # We assume that there are enough miscellaneous allocations that an allocation
 # exactly as large as the limit will always fail.
 ok_xmalloc "malloc fail" 1 \
-    "failed to malloc 30000000 bytes at xmalloc.c line 41" \
+    "failed to malloc 30000000 bytes at xmalloc.c line 42" \
     "m" "30000000" "30000000"
 ok_xmalloc "realloc fail" 1 \
-    "failed to realloc 30000000 bytes at xmalloc.c line 69" \
+    "failed to realloc 30000000 bytes at xmalloc.c line 71" \
     "r" "30000000" "30000000"
 ok_xmalloc "reallocarray fail" 1 \
-    "failed to reallocarray 30000000 bytes at xmalloc.c line 99" \
+    "failed to reallocarray 30000000 bytes at xmalloc.c line 100" \
     "y" "30000000" "30000000"
 ok_xmalloc "strdup fail" 1 \
-    "failed to strdup 30000000 bytes at xmalloc.c line 130" \
+    "failed to strdup 30000000 bytes at xmalloc.c line 131" \
     "s" "30000000" "30000000"
 ok_xmalloc "strndup fail" 1 \
-    "failed to strndup 30000000 bytes at xmalloc.c line 176" \
+    "failed to strndup 30000000 bytes at xmalloc.c line 177" \
     "n" "30000000" "30000000"
 ok_xmalloc "calloc fail" 1 \
-    "failed to calloc 30000000 bytes at xmalloc.c line 200" \
+    "failed to calloc 30000000 bytes at xmalloc.c line 201" \
     "c" "30000000" "30000000"
 ok_xmalloc "asprintf fail" 1 \
-    "failed to asprintf 30000000 bytes at xmalloc.c line 224" \
+    "failed to asprintf 30000000 bytes at xmalloc.c line 225" \
     "a" "30000000" "30000000"
 ok_xmalloc "vasprintf fail" 1 \
-    "failed to vasprintf 30000000 bytes at xmalloc.c line 243" \
+    "failed to vasprintf 30000000 bytes at xmalloc.c line 244" \
     "v" "30000000" "30000000"
 
 # Check our custom error handler.
-ok_xmalloc "malloc custom"       1 "malloc 30000000 xmalloc.c 41" \
+ok_xmalloc "malloc custom"       1 "malloc 30000000 xmalloc.c 42" \
     "M" "30000000" "30000000"
-ok_xmalloc "realloc custom"      1 "realloc 30000000 xmalloc.c 69" \
+ok_xmalloc "realloc custom"      1 "realloc 30000000 xmalloc.c 71" \
     "R" "30000000" "30000000"
-ok_xmalloc "reallocarray custom" 1 "reallocarray 30000000 xmalloc.c 99" \
+ok_xmalloc "reallocarray custom" 1 "reallocarray 30000000 xmalloc.c 100" \
     "Y" "30000000" "30000000"
-ok_xmalloc "strdup custom"       1 "strdup 30000000 xmalloc.c 130" \
+ok_xmalloc "strdup custom"       1 "strdup 30000000 xmalloc.c 131" \
     "S" "30000000" "30000000"
-ok_xmalloc "strndup custom"      1 "strndup 30000000 xmalloc.c 176" \
+ok_xmalloc "strndup custom"      1 "strndup 30000000 xmalloc.c 177" \
     "N" "30000000" "30000000"
-ok_xmalloc "calloc custom"       1 "calloc 30000000 xmalloc.c 200" \
+ok_xmalloc "calloc custom"       1 "calloc 30000000 xmalloc.c 201" \
     "C" "30000000" "30000000"
-ok_xmalloc "asprintf custom"     1 "asprintf 30000000 xmalloc.c 224" \
+ok_xmalloc "asprintf custom"     1 "asprintf 30000000 xmalloc.c 225" \
     "A" "30000000" "30000000"
-ok_xmalloc "vasprintf custom"    1 "vasprintf 30000000 xmalloc.c 243" \
+ok_xmalloc "vasprintf custom"    1 "vasprintf 30000000 xmalloc.c 244" \
     "V" "30000000" "30000000"
 
 # Check the smaller ones again just for grins.
index 8ff1a2360ac6fb8e165d8345b7457c36da1fed8c..eb6f1d2c83d3cafc177abd93c98cb485bce4d4de 100644 (file)
@@ -4,8 +4,8 @@
  * The canonical version of this file is maintained in the rra-c-util package,
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
- * Copyright 2000, 2001, 2006 Russ Allbery <eagle@eyrie.org>
- * Copyright 2008, 2012, 2013, 2014
+ * Copyright 2000-2001, 2006, 2017, 2020 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2008, 2012-2014
  *     The Board of Trustees of the Leland Stanford Junior University
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -25,6 +25,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
  */
 
 #line 1 "xmalloc.c"
@@ -32,6 +34,7 @@
 #include <config.h>
 #include <portable/system.h>
 
+#include <assert.h>
 #include <ctype.h>
 #include <errno.h>
 #ifdef HAVE_SYS_TIME_H
@@ -50,7 +53,7 @@
  * A customized error handler for checking xmalloc's support of them.  Prints
  * out the error message and exits with status 1.
  */
-static void
+static void __attribute__((__noreturn__))
 test_handler(const char *function, size_t size, const char *file, int line)
 {
     die("%s %lu %s %d", function, (unsigned long) size, file, line);
@@ -92,6 +95,7 @@ test_realloc(size_t size)
     char *buffer;
     size_t i;
 
+    assert(size > 10);
     buffer = xmalloc(10);
     if (buffer == NULL)
         return 0;
@@ -99,8 +103,7 @@ test_realloc(size_t size)
     buffer = xrealloc(buffer, size);
     if (buffer == NULL)
         return 0;
-    if (size > 0)
-        memset(buffer + 10, 2, size - 10);
+    memset(buffer + 10, 2, size - 10);
     for (i = 0; i < 10; i++)
         if (buffer[i] != 1)
             return 0;
@@ -327,7 +330,7 @@ main(int argc, char *argv[])
     code = argv[1][0];
     if (isupper(code)) {
         xmalloc_error_handler = test_handler;
-        code = tolower(code);
+        code = (unsigned char) tolower(code);
     }
 
     /*
@@ -381,26 +384,19 @@ main(int argc, char *argv[])
 #endif
     }
 
+    /* clang-format off */
     switch (code) {
-    case 'c':
-        exit(test_calloc(size) ? willfail : 1);
-    case 'm':
-        exit(test_malloc(size) ? willfail : 1);
-    case 'r':
-        exit(test_realloc(size) ? willfail : 1);
-    case 'y':
-        exit(test_reallocarray(4, size / 4) ? willfail : 1);
-    case 's':
-        exit(test_strdup(size) ? willfail : 1);
-    case 'n':
-        exit(test_strndup(size) ? willfail : 1);
-    case 'a':
-        exit(test_asprintf(size) ? willfail : 1);
-    case 'v':
-        exit(test_vasprintf(size) ? willfail : 1);
-    default:
-        die("Unknown mode %c", argv[1][0]);
-        break;
+    case 'c': exit(test_calloc(size) ? willfail : 1);
+    case 'm': exit(test_malloc(size) ? willfail : 1);
+    case 'r': exit(test_realloc(size) ? willfail : 1);
+    case 'y': exit(test_reallocarray(4, size / 4) ? willfail : 1);
+    case 's': exit(test_strdup(size) ? willfail : 1);
+    case 'n': exit(test_strndup(size) ? willfail : 1);
+    case 'a': exit(test_asprintf(size) ? willfail : 1);
+    case 'v': exit(test_vasprintf(size) ? willfail : 1);
+    default:  die("Unknown mode %c", argv[1][0]);
     }
+    /* clang-format on */
+
     exit(1);
 }
index 543b6c5e36269d377fb72f8619f27816653d1669..6ca0a0c533c639f1885b1b7c0c6e03ac8371d93c 100755 (executable)
@@ -313,7 +313,7 @@ sub find_iteration_count {
     require Benchmark;
     my $iterations = $HASH_ITERATIONS;
     while (1) {
-        my $hash = sub { password_hash($password, $iterations) };
+        my $hash  = sub { password_hash($password, $iterations) };
         my $times = Benchmark::timethis(20, $hash, q{}, 'none');
 
         # Extract the CPU time from the formatted time string.  This will be
@@ -498,7 +498,7 @@ sub strength_check {
 
     # Run the external quality checking program.  If we're root, we'll run it
     # as the strength checking user and group.
-    my $in = "principal: $principal\nnew-password: $password\nend\n";
+    my $in   = "principal: $principal\nnew-password: $password\nend\n";
     my $init = sub { drop_privileges($STRENGTH_USER, $STRENGTH_GROUP) };
     my ($out, $err);
     run([$path, $principal], \$in, \$out, \$err, init => $init);
index d6f292f1b7db425469073c9e9465540ae5c28c0a..7cb86a67271873b3945bde6083829d1e00f247e2 100644 (file)
@@ -7,6 +7,7 @@
  * dictionary.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2020 Russ Allbery <eagle@eyrie.org>
  * Copyright 2009, 2013
  *     The Board of Trustees of the Leland Stanford Junior University
  *
@@ -35,8 +36,9 @@ static void
 read_key(const char *key, char *buffer, size_t length)
 {
     char *p;
+    int size = (length < INT_MAX) ? (int) length : INT_MAX;
 
-    if (fgets(buffer, length, stdin) == NULL)
+    if (fgets(buffer, size, stdin) == NULL)
         sysdie("Cannot read %s", key);
     if (strlen(buffer) < 1 || buffer[strlen(buffer) - 1] != '\n')
         die("Malformed or too long %s line", key);
index 8b82d56107ed3b8d7db4d8c35f0ffb3530b84043..612a88cf141b85c3aa3e3394e40b479fde3d11db 100644 (file)
@@ -5,14 +5,16 @@
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2014 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2008-2011
+ *     The Board of Trustees of the Leland Stanford Junior University
  *
- * The authors hereby relinquish any claim to any copyright that they may have
- * in this work, whether granted under contract or by operation of law or
- * international treaty, and hereby commit to the public, at large, that they
- * shall not, at any time in the future, seek to enforce any copyright in this
- * work against any person or entity, or prevent any person or entity from
- * copying, publishing, distributing or creating derivative works of this
- * work.
+ * Copying and distribution of this file, with or without modification, are
+ * permitted in any medium without royalty provided the copyright notice and
+ * this notice are preserved.  This file is offered as-is, without any
+ * warranty.
+ *
+ * SPDX-License-Identifier: FSFAP
  */
 
 #ifndef UTIL_MACROS_H
index f00289af2ae794af8bcc90500fb13c8d89006688..435369e17546aff70b31cd950a4f999b67c8ef4c 100644 (file)
@@ -9,7 +9,7 @@
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2006, 2007, 2008, 2009, 2010, 2013
+ * Copyright 2006-2010, 2013
  *     The Board of Trustees of the Leland Stanford Junior University
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -29,6 +29,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 <config.h>
index 63e72ec410abc673f66f872eb52bd28e9f07fbce..da96e4c66127d2147161f26c8bb3f0c7abe07c51 100644 (file)
@@ -5,7 +5,7 @@
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2006, 2007, 2008, 2009, 2010, 2013
+ * Copyright 2006-2010, 2013
  *     The Board of Trustees of the Leland Stanford Junior University
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -25,6 +25,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
  */
 
 #ifndef UTIL_MESSAGES_KRB5_H
index cf6f8378a4fe12916c0870bb5b9a6a13baf106e7..0e79a4397db346ce4ece104e375459d44dc5c1e1 100644 (file)
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2015, 2016 Russ Allbery <eagle@eyrie.org>
- * Copyright 2008, 2009, 2010, 2013, 2014
+ * Copyright 2015-2016, 2020 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2008-2010, 2013-2014
  *     The Board of Trustees of the Leland Stanford Junior University
- * Copyright (c) 2004, 2005, 2006
- *     by Internet Systems Consortium, Inc. ("ISC")
- * Copyright (c) 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
- *     2002, 2003 by The Internet Software Consortium and Rich Salz
+ * Copyright 2004-2006 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright 1991, 1994-2003 The Internet Software Consortium and Rich Salz
  *
  * This code is derived from software contributed to the Internet Software
  * Consortium by Rich Salz.
@@ -76,6 +74,8 @@
  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * SPDX-License-Identifier: ISC
  */
 
 #include <config.h>
@@ -140,15 +140,18 @@ message_handlers(message_handler_func **list, unsigned int count, va_list args)
  * duplication since we can't assume variadic macros, but I can at least make
  * it easier to write and keep them consistent.
  */
-#define HANDLER_FUNCTION(type)                            \
-    void message_handlers_##type(unsigned int count, ...) \
-    {                                                     \
-        va_list args;                                     \
-                                                          \
-        va_start(args, count);                            \
-        message_handlers(&type##_handlers, count, args);  \
-        va_end(args);                                     \
+/* clang-format off */
+#define HANDLER_FUNCTION(type)                              \
+    void                                                    \
+    message_handlers_ ## type(unsigned int count, ...)      \
+    {                                                       \
+        va_list args;                                       \
+                                                            \
+        va_start(args, count);                              \
+        message_handlers(& type ## _handlers, count, args); \
+        va_end(args);                                       \
     }
+/* clang-format on */
 HANDLER_FUNCTION(debug)
 HANDLER_FUNCTION(notice)
 HANDLER_FUNCTION(warn)
@@ -263,17 +266,20 @@ message_log_syslog(int pri, size_t len, const char *fmt, va_list args, int err)
  * Do the same sort of wrapper to generate all of the separate syslog logging
  * functions.
  */
-#define SYSLOG_FUNCTION(name, type)                                           \
-    void message_log_syslog_##name(size_t l, const char *f, va_list a, int e) \
-    {                                                                         \
-        message_log_syslog(LOG_##type, l, f, a, e);                           \
+/* clang-format off */
+#define SYSLOG_FUNCTION(name, type)                                        \
+    void                                                                   \
+    message_log_syslog_ ## name(size_t l, const char *f, va_list a, int e) \
+    {                                                                      \
+        message_log_syslog(LOG_ ## type, l, f, a, e);                      \
     }
-SYSLOG_FUNCTION(debug, DEBUG)
-SYSLOG_FUNCTION(info, INFO)
-SYSLOG_FUNCTION(notice, NOTICE)
+SYSLOG_FUNCTION(debug,   DEBUG)
+SYSLOG_FUNCTION(info,    INFO)
+SYSLOG_FUNCTION(notice,  NOTICE)
 SYSLOG_FUNCTION(warning, WARNING)
-SYSLOG_FUNCTION(err, ERR)
-SYSLOG_FUNCTION(crit, CRIT)
+SYSLOG_FUNCTION(err,     ERR)
+SYSLOG_FUNCTION(crit,    CRIT)
+/* clang-format on */
 
 
 /*
index 555792bcf1476f2c8811d1f3f309a61093b4220d..3620273aa1ce1a080f8038e276f7935d823d57f2 100644 (file)
@@ -6,12 +6,10 @@
  *
  * Written by Russ Allbery <eagle@eyrie.org>
  * Copyright 2015 Russ Allbery <eagle@eyrie.org>
- * Copyright 2008, 2010, 20132014
+ * Copyright 2008, 2010, 2013-2014
  *     The Board of Trustees of the Leland Stanford Junior University
- * Copyright (c) 2004, 2005, 2006
- *     by Internet Systems Consortium, Inc. ("ISC")
- * Copyright (c) 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
- *     2002, 2003 by The Internet Software Consortium and Rich Salz
+ * Copyright 2004-2006 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright 1991, 1994-2003 The Internet Software Consortium and Rich Salz
  *
  * This code is derived from software contributed to the Internet Software
  * Consortium by Rich Salz.
@@ -27,6 +25,8 @@
  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * SPDX-License-Identifier: ISC
  */
 
 #ifndef UTIL_MESSAGES_H
index fc6839eef939eb5f1e1ffe41b48f916a8af8a989..e8a9a82599cc3c52b97d697c6b8149cc55402072 100644 (file)
  * The canonical version of this file is maintained in the rra-c-util package,
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
+ * Written by Russ Allbery <eagle@eyrie.org>
  * Copyright 2015 Russ Allbery <eagle@eyrie.org>
- * Copyright 2012, 2013, 2014
+ * Copyright 2012-2014
  *     The Board of Trustees of the Leland Stanford Junior University
- * Copyright (c) 2004, 2005, 2006
- *     by Internet Systems Consortium, Inc. ("ISC")
- * Copyright (c) 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
- *     2002, 2003 by The Internet Software Consortium and Rich Salz
+ * Copyright 2004-2006 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright 1991, 1994-2003 The Internet Software Consortium and Rich Salz
  *
  * This code is derived from software contributed to the Internet Software
  * Consortium by Rich Salz.
@@ -84,6 +83,8 @@
  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * SPDX-License-Identifier: ISC
  */
 
 #include <config.h>
index bdb76d95c093afcd80128a0003b5ee322a48b731..02c5431fd09918fd4c8edf5223c1db5eba898aee 100644 (file)
@@ -4,12 +4,11 @@
  * The canonical version of this file is maintained in the rra-c-util package,
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
- * Copyright 2010, 2012, 2013, 2014
+ * Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2010, 2012-2014
  *     The Board of Trustees of the Leland Stanford Junior University
- * Copyright (c) 2004, 2005, 2006
- *     by Internet Systems Consortium, Inc. ("ISC")
- * Copyright (c) 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
- *     2002, 2003 by The Internet Software Consortium and Rich Salz
+ * Copyright 2004-2006 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright 1991, 1994-2003 The Internet Software Consortium and Rich Salz
  *
  * This code is derived from software contributed to the Internet Software
  * Consortium by Rich Salz.
@@ -25,6 +24,8 @@
  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * SPDX-License-Identifier: ISC
  */
 
 #ifndef UTIL_XMALLOC_H
@@ -110,7 +111,7 @@ typedef void (*xmalloc_handler_type)(const char *, size_t, const char *, int);
 
 /* The default error handler. */
 void xmalloc_fail(const char *, size_t, const char *, int)
-    __attribute__((__nonnull__));
+    __attribute__((__nonnull__, __noreturn__));
 
 /*
  * Assign to this variable to choose a handler other than the default, which