From d718331e59afb35e56445f3a1597ed74a7f3a3e2 Mon Sep 17 00:00:00 2001 From: Nicolas Iooss Date: Sat, 4 Jan 2014 03:03:51 +0000 Subject: copy: fix a segfault in SELinux context copying code * src/selinux.c (restorecon_private): On ArchLinux the `fakeroot cp -a file1 file2` command segfaulted due to getfscreatecon() returning a NULL context. So map this to the sometimes ignored ENODATA error, rather than crashing. * tests/cp/no-ctx.sh: Add a new test case. * tests/local.mk: Reference the new test. * NEWS: Mention the fix. Fixes http://bugs.gnu.org/16335 --- src/selinux.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/selinux.c') diff --git a/src/selinux.c b/src/selinux.c index cd38a81e8..016db1626 100644 --- a/src/selinux.c +++ b/src/selinux.c @@ -192,6 +192,11 @@ restorecon_private (char const *path, bool local) { if (getfscreatecon (&tcon) < 0) return rc; + if (!tcon) + { + errno = ENODATA; + return rc; + } rc = lsetfilecon (path, tcon); freecon (tcon); return rc; -- cgit v1.2.3-54-g00ecf