From 8b898b2ca23d68409673bbfc9829b1c60a06f32a Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Wed, 9 Nov 2022 12:58:41 -0700 Subject: [PATCH] Test parsing LDIF when a backslash is the last char of the file. If run with address sanitizer, this test will crash when the fix in ceaf706ab74b is reverted. --- MANIFEST | 2 ++ plugins/sudoers/Makefile.in | 2 +- plugins/sudoers/regress/cvtsudoers/test39.out.ok | 0 plugins/sudoers/regress/cvtsudoers/test39.sh | 11 +++++++++++ plugins/sudoers/regress/harness.in | 2 +- 5 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 plugins/sudoers/regress/cvtsudoers/test39.out.ok create mode 100644 plugins/sudoers/regress/cvtsudoers/test39.sh diff --git a/MANIFEST b/MANIFEST index ed456e6f2..a8dc3fd65 100644 --- a/MANIFEST +++ b/MANIFEST @@ -804,6 +804,8 @@ plugins/sudoers/regress/cvtsudoers/test37.out.ok plugins/sudoers/regress/cvtsudoers/test37.sh plugins/sudoers/regress/cvtsudoers/test38.out.ok plugins/sudoers/regress/cvtsudoers/test38.sh +plugins/sudoers/regress/cvtsudoers/test39.out.ok +plugins/sudoers/regress/cvtsudoers/test39.sh plugins/sudoers/regress/cvtsudoers/test4.out.ok plugins/sudoers/regress/cvtsudoers/test4.sh plugins/sudoers/regress/cvtsudoers/test5.out.ok diff --git a/plugins/sudoers/Makefile.in b/plugins/sudoers/Makefile.in index 29110dcfd..2d9bde8d0 100644 --- a/plugins/sudoers/Makefile.in +++ b/plugins/sudoers/Makefile.in @@ -337,7 +337,7 @@ depend: cd $(top_builddir) && ./config.status --file plugins/sudoers/Makefile harness: $(srcdir)/regress/harness.in - cd $(top_builddir) && ./config.status --file plugins/sudoers/regress/harness + cd $(top_builddir) && ./config.status --file plugins/sudoers/regress/harness && chmod +x plugins/sudoers/regress/harness Makefile: $(srcdir)/Makefile.in cd $(top_builddir) && ./config.status --file plugins/sudoers/Makefile diff --git a/plugins/sudoers/regress/cvtsudoers/test39.out.ok b/plugins/sudoers/regress/cvtsudoers/test39.out.ok new file mode 100644 index 000000000..e69de29bb diff --git a/plugins/sudoers/regress/cvtsudoers/test39.sh b/plugins/sudoers/regress/cvtsudoers/test39.sh new file mode 100644 index 000000000..4c172d25e --- /dev/null +++ b/plugins/sudoers/regress/cvtsudoers/test39.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# +# Test handling of a backslash at EOF with no trailing newline. +# +# If compiled with address sanitizer, cvtsudoers will crash without +# the fix in ceaf706ab74b. +# + +: ${CVTSUDOERS=cvtsudoers} + +printf 'dn: cn= Manager\\' | $CVTSUDOERS -c "" -b dc=sudo,dc=ws -i ldif -f sudoers diff --git a/plugins/sudoers/regress/harness.in b/plugins/sudoers/regress/harness.in index caa8b63ba..9aa6e7677 100755 --- a/plugins/sudoers/regress/harness.in +++ b/plugins/sudoers/regress/harness.in @@ -189,8 +189,8 @@ sudoers) echo "$group/$test: FAIL" diff $out $out_ok || true fi + ntests=`expr $ntests + 1` if test -s $err_ok; then - ntests=`expr $ntests + 1` if cmp $err $err_ok >/dev/null; then if [ $verbose -eq 1 ]; then echo "$group/$test (stderr): OK"