mknod/mkfifo segfault fix(upstream)

This commit is contained in:
Ondrej Vasik 2008-03-29 17:14:21 +00:00
parent 0089801a1e
commit 829da0db5b
4 changed files with 123 additions and 17 deletions

View File

@ -88,15 +88,14 @@ diff -urNp coreutils-6.10-orig/tests/misc/chcon coreutils-6.10/tests/misc/chcon
diff -urNp coreutils-6.10-orig/tests/misc/factor coreutils-6.10/tests/misc/factor
--- coreutils-6.10-orig/tests/misc/factor 2007-12-13 00:14:28.000000000 +0100
+++ coreutils-6.10/tests/misc/factor 2008-03-28 13:49:34.000000000 +0100
@@ -71,7 +71,7 @@ my @Tests =
@@ -71,6 +71,7 @@ my @Tests =
['x', '4294966896', {OUT => '2 2 2 2 3 3 3 11 607 1489'}],
['y', '4294966998', {OUT => '2 3 7 3917 26107'}],
['z', '-1',
- {ERR => "$prog: invalid option -- 1\n"
+ {ERR => "$prog: invalid option -- '1'\n"
+ {ERR_SUBST => q!s/'1'/1/!}, # map newer glibc diagnostic to expected.
{ERR => "$prog: invalid option -- 1\n"
. "Try `$prog --help' for more information.\n"},
{EXIT => 1}],
['cont', 'a 4',
diff -urNp coreutils-6.10-orig/tests/cp/cp-a-selinux coreutils-6.10/tests/cp/cp-a-selinux
--- coreutils-6.10-orig/tests/cp/cp-a-selinux 2008-01-05 23:59:11.000000000 +0100
+++ coreutils-6.10/tests/cp/cp-a-selinux 2008-03-26 13:52:24.000000000 +0100

View File

@ -1,15 +1,3 @@
diff -urNp coreutils-6.10-orig/src/mkdir.c coreutils-6.10/src/mkdir.c
--- coreutils-6.10-orig/src/mkdir.c 2008-03-27 14:42:40.000000000 +0100
+++ coreutils-6.10/src/mkdir.c 2008-03-27 14:51:48.000000000 +0100
@@ -211,7 +211,7 @@ main (int argc, char **argv)
if (scontext && setfscreatecon (scontext) < 0)
error (EXIT_FAILURE, errno,
_("failed to set default file creation context to %s"),
- quote (optarg));
+ quote (scontext));
if (options.make_ancestor_function || specified_mode)
{
diff -urNp coreutils-6.10-orig/src/paste.c coreutils-6.10/src/paste.c
--- coreutils-6.10-orig/src/paste.c 2007-11-25 14:23:31.000000000 +0100
+++ coreutils-6.10/src/paste.c 2008-03-27 14:47:02.000000000 +0100

View File

@ -0,0 +1,112 @@
diff -urNp coreutils-6.10-orig/src/mkdir.c coreutils-6.10/src/mkdir.c
--- coreutils-6.10-orig/src/mkdir.c 2008-03-27 14:42:40.000000000 +0100
+++ coreutils-6.10/src/mkdir.c 2008-03-27 14:51:48.000000000 +0100
@@ -211,7 +211,7 @@ main (int argc, char **argv)
if (scontext && setfscreatecon (scontext) < 0)
error (EXIT_FAILURE, errno,
_("failed to set default file creation context to %s"),
- quote (optarg));
+ quote (scontext));
if (options.make_ancestor_function || specified_mode)
{
diff -urNp coreutils-6.10-orig/src/mkfifo.c coreutils-6.10/src/mkfifo.c
--- coreutils-6.10-orig/src/mkfifo.c 2008-03-29 17:53:27.000000000 +0100
+++ coreutils-6.10/src/mkfifo.c 2008-03-29 17:55:44.000000000 +0100
@@ -1,5 +1,5 @@
/* mkfifo -- make fifo's (named pipes)
- Copyright (C) 90, 91, 1995-2007 Free Software Foundation, Inc.
+ Copyright (C) 90, 91, 1995-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
@@ -123,7 +123,7 @@ main (int argc, char **argv)
if (scontext && setfscreatecon (scontext) < 0)
error (EXIT_FAILURE, errno,
_("failed to set default file creation context to %s"),
- quote (optarg));
+ quote (scontext));
newmode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
if (specified_mode)
diff -urNp coreutils-6.10-orig/src/mknod.c coreutils-6.10/src/mknod.c
--- coreutils-6.10-orig/src/mknod.c 2008-03-29 17:53:27.000000000 +0100
+++ coreutils-6.10/src/mknod.c 2008-03-29 17:55:36.000000000 +0100
@@ -175,7 +175,7 @@ main (int argc, char **argv)
if (scontext && setfscreatecon (scontext) < 0)
error (EXIT_FAILURE, errno,
_("failed to set default file creation context to %s"),
- quote (optarg));
+ quote (scontext));
/* Only check the first character, to allow mnemonic usage like
`mknod /dev/rst0 character 18 0'. */
Binární soubory coreutils-6.10-orig/src/.mknod.c.swp a coreutils-6.10/src/.mknod.c.swp jsou různé
diff -urNp coreutils-6.10-orig/tests/mkdir/Makefile.am coreutils-6.10/tests/mkdir/Makefile.am
--- coreutils-6.10-orig/tests/mkdir/Makefile.am 2007-11-25 14:23:31.000000000 +0100
+++ coreutils-6.10/tests/mkdir/Makefile.am 2008-03-29 17:56:51.000000000 +0100
@@ -8,6 +8,7 @@ TESTS = \
p-v \
parents \
perm \
+ selinux \
special-1 \
t-slash \
writable-under-readonly
diff -urNp coreutils-6.10-orig/tests/mkdir/selinux coreutils-6.10/tests/mkdir/selinux
--- coreutils-6.10-orig/tests/mkdir/selinux 1970-01-01 01:00:00.000000000 +0100
+++ coreutils-6.10/tests/mkdir/selinux 2008-03-29 17:58:25.000000000 +0100
@@ -0,0 +1,53 @@
+#!/bin/sh
+# ensure that an invalid context doesn't cause a segfault
+
+# 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
+ mkdir --version
+ mkfifo --version
+ mknod --version
+fi
+
+. $srcdir/../envvar-check
+. $srcdir/../lang-default
+. $srcdir/../test-lib.sh
+
+c=invalid-selinux-context
+
+fail=0
+mkdir -Z $c dir-arg 2> out && fail=1
+cat <<EOF > exp || fail=1
+mkdir: failed to set default file creation context to \`$c': Invalid argument
+EOF
+compare out exp || fail=1
+
+# Until coreutils-6.10.150, mknod and mkfifo had the same problem:
+
+mknod -Z $c b p 2> out && fail=1
+cat <<EOF > exp || fail=1
+mknod: failed to set default file creation context to \`$c': Invalid argument
+EOF
+compare out exp || fail=1
+
+mkfifo -Z $c f 2> out && fail=1
+cat <<EOF > exp || fail=1
+mkfifo: failed to set default file creation context to \`$c': Invalid argument
+EOF
+compare out exp || fail=1
+
+(exit $fail); exit $fail

View File

@ -1,7 +1,7 @@
Summary: The GNU core utilities: a set of tools commonly used in shell scripts
Name: coreutils
Version: 6.10
Release: 16%{?dist}
Release: 17%{?dist}
License: GPLv3+
Group: System Environment/Base
Url: http://www.gnu.org/software/coreutils/
@ -22,6 +22,7 @@ Patch1: coreutils-6.10-verbose.patch
Patch2: coreutils-dddoubleclose.patch
Patch3: coreutils-mvatomic.patch
Patch4: coreutils-6.10-lonebackslash.patch
Patch5: coreutils-6.10-mkscontextsegfault.patch
# Our patches
Patch100: coreutils-chgrp.patch
@ -103,6 +104,7 @@ cd %name-%version
%patch2 -p1 -b .doubleclose
%patch3 -p1 -b .atomic
%patch4 -p1 -b .backslash
%patch5 -p1 -b .mksegfault
# Our patches
%patch100 -p1 -b .chgrp
@ -132,6 +134,7 @@ cd %name-%version
%patch950 -p1 -b .selinux
chmod a+x tests/sort/sort-mb-tests
chmod a+x tests/mkdir/selinux
%build
%ifarch s390 s390x
@ -299,6 +302,10 @@ fi
/sbin/runuser
%changelog
* Sat Mar 29 2008 Ondrej Vasik <ovasik@redhat.com> - 6.10-17
- better workaround of glibc getoptc change(factor test)
- don't segfault mknod, mkfifo with invalid-selinux-context
* Thu Mar 27 2008 Ondrej Vasik <ovasik@redhat.com> - 6.10-16
- keep LS_COLORS when USER_LS_COLORS defined
- someupstream fixes: