mirror of
https://github.com/FAUSheppy/colorredstderr-mirror
synced 2025-12-09 16:38:32 +01:00
Fix possible memory overwrite in init_from_environment().
It was possible for a user to overwrite memory at a relative location with 1 by passing a negative file descriptor.
This commit is contained in:
27
tests/lib.sh
27
tests/lib.sh
@@ -40,6 +40,9 @@ fi
|
||||
LC_ALL=C
|
||||
unset LANGUAGE
|
||||
|
||||
# Set default COLORED_STDERR_FDS value.
|
||||
fds=2,
|
||||
|
||||
|
||||
die() {
|
||||
echo "$@" >&2
|
||||
@@ -75,7 +78,7 @@ run_test() {
|
||||
(
|
||||
# Standard setup.
|
||||
LD_PRELOAD="$library"
|
||||
COLORED_STDERR_FDS=2,
|
||||
COLORED_STDERR_FDS="$fds"
|
||||
export LD_PRELOAD
|
||||
export COLORED_STDERR_FDS
|
||||
|
||||
@@ -101,17 +104,27 @@ run_test() {
|
||||
|
||||
test_script() {
|
||||
testcase="$1"
|
||||
shift
|
||||
run_test "$srcdir/$testcase" "$srcdir/$testcase.expected" "$@"
|
||||
expected="$2"
|
||||
shift; shift || true
|
||||
|
||||
if test -z "$expected"; then
|
||||
expected="$testcase"
|
||||
fi
|
||||
run_test "$srcdir/$testcase" "$srcdir/$expected.expected" "$@"
|
||||
}
|
||||
test_script_subshell() {
|
||||
test_script "$1" bash -c 'bash $1' ''
|
||||
test_script "$1" "$2" bash -c 'bash $1' ''
|
||||
}
|
||||
test_program() {
|
||||
testcase="$1"
|
||||
shift
|
||||
run_test "$builddir/$testcase" "$srcdir/$testcase.expected" "$@"
|
||||
expected="$2"
|
||||
shift; shift || true
|
||||
|
||||
if test -z "$expected"; then
|
||||
expected="$testcase"
|
||||
fi
|
||||
run_test "$builddir/$testcase" "$srcdir/$expected.expected" "$@"
|
||||
}
|
||||
test_program_subshell() {
|
||||
test_program "$1" sh -c '$1' ''
|
||||
test_program "$1" "$2" sh -c '$1' ''
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user