summaryrefslogtreecommitdiff
path: root/tests/ls
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2008-01-29 08:56:48 +0100
committerJim Meyering <meyering@redhat.com>2008-01-29 09:23:51 +0100
commit533391a2a75f49da27adc71214caeeb4ef07d81c (patch)
tree9844aa22b4d1ce561e46e7b5973b7f2ed88b8309 /tests/ls
parenta6228c5437e9f07d9f72828436b75e3358443a1c (diff)
downloadcoreutils-533391a2a75f49da27adc71214caeeb4ef07d81c.tar.xz
ls: don't segfault on files in /proc with an old libselinux
* src/ls.c (gobble_file): Work around a bug in libselinux1-2.0.15 whereby getfilecon returns 0 yet sets the context to NULL. Reported by Jan Moringen via Michael Stone in http://bugs.debian.org/463043 * tests/ls/Makefile.am (TESTS): Add proc-selinux-segfault. * tests/ls/proc-selinux-segfault: Test for the above fix. * NEWS: Mention the fix.
Diffstat (limited to 'tests/ls')
-rw-r--r--tests/ls/Makefile.am3
-rwxr-xr-xtests/ls/proc-selinux-segfault33
2 files changed, 35 insertions, 1 deletions
diff --git a/tests/ls/Makefile.am b/tests/ls/Makefile.am
index 2aea41951..c9739c992 100644
--- a/tests/ls/Makefile.am
+++ b/tests/ls/Makefile.am
@@ -1,6 +1,6 @@
# Make coreutils tests for "ls". -*-Makefile-*-
-# Copyright (C) 1997-2003, 2006-2007 Free Software Foundation, Inc.
+# Copyright (C) 1997-2003, 2006-2008 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
TESTS = \
+ proc-selinux-segfault \
stat-free-symlinks \
nameless-uid \
color-dtype-dir \
diff --git a/tests/ls/proc-selinux-segfault b/tests/ls/proc-selinux-segfault
new file mode 100755
index 000000000..320ba6f24
--- /dev/null
+++ b/tests/ls/proc-selinux-segfault
@@ -0,0 +1,33 @@
+#!/bin/sh
+# ls -l /proc/sys would segfault when built against libselinux1 2.0.15-2+b1
+
+# Copyright (C) 2008 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+if test "$VERBOSE" = yes; then
+ set -x
+ ls --version
+fi
+
+. $srcdir/../envvar-check
+. $srcdir/../test-lib.sh
+
+f=/proc/sys
+test -r $f || f=.
+
+fail=0
+ls -l $f > out || fail=1
+
+(exit $fail); exit $fail