libselinux: label_file: handle newlines in file names

restorecon on file names with newlines are not handled properly.
Use PCRE_DOTALL so that dots in regular expressions match all
characters, and don't exclude the newline character.

See https://www.mail-archive.com/seandroid-list@tycho.nsa.gov/msg02001.html
for background.

Change-Id: I0dde8f2567305f746d19ebd75a9e2add7406eb9a
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
This commit is contained in:
Nick Kralevich 2015-02-23 21:46:52 -08:00 committed by Stephen Smalley
parent b2beb5304d
commit 716e3820c5

View File

@ -129,7 +129,7 @@ static int compile_regex(struct saved_data *data, struct spec *spec, const char
*cp = '\0';
/* Compile the regular expression. */
spec->regex = pcre_compile(anchored_regex, 0, &tmperrbuf, &erroff, NULL);
spec->regex = pcre_compile(anchored_regex, PCRE_DOTALL, &tmperrbuf, &erroff, NULL);
free(anchored_regex);
if (!spec->regex) {
if (errbuf)