2f49e0
diff --git libselinux-2.7/Makefile libselinux-2.7/Makefile
f2f46e
index 1ecab17..16531fe 100644
2f49e0
--- libselinux-2.7/Makefile
2f49e0
+++ libselinux-2.7/Makefile
f2f46e
@@ -21,13 +21,14 @@ export DISABLE_SETRANS DISABLE_RPM DISABLE_FLAGS ANDROID_HOST
e58e94
 
f2f46e
 USE_PCRE2 ?= n
f2f46e
 ifeq ($(USE_PCRE2),y)
f2f46e
-	PCRE_CFLAGS := -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8 $(shell $(PKG_CONFIG) --cflags libpcre2-8)
f2f46e
-	PCRE_LDLIBS := $(shell $(PKG_CONFIG) --libs libpcre2-8)
f2f46e
+	PCRE_MODULE := libpcre2-8
f2f46e
+	PCRE_CFLAGS := -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8
f2f46e
 else
f2f46e
-	PCRE_CFLAGS := $(shell $(PKG_CONFIG) --cflags libpcre)
f2f46e
-	PCRE_LDLIBS := $(shell $(PKG_CONFIG) --libs libpcre)
f2f46e
+	PCRE_MODULE := libpcre
f2f46e
 endif
f2f46e
-export PCRE_CFLAGS PCRE_LDLIBS
f2f46e
+PCRE_CFLAGS += $(shell $(PKG_CONFIG) --cflags $(PCRE_MODULE))
f2f46e
+PCRE_LDLIBS := $(shell $(PKG_CONFIG) --libs $(PCRE_MODULE))
f2f46e
+export PCRE_MODULE PCRE_CFLAGS PCRE_LDLIBS
f2f46e
 
f2f46e
 OS := $(shell uname)
f2f46e
 export OS
2f49e0
diff --git libselinux-2.7/man/man8/selinux.8 libselinux-2.7/man/man8/selinux.8
2f49e0
index e37aee6..bf23b65 100644
2f49e0
--- libselinux-2.7/man/man8/selinux.8
2f49e0
+++ libselinux-2.7/man/man8/selinux.8
e58e94
@@ -91,11 +91,13 @@ This manual page was written by Dan Walsh <dwalsh@redhat.com>.
e58e94
 .BR sepolicy (8),
e58e94
 .BR system-config-selinux (8),
e58e94
 .BR togglesebool (8),
e58e94
-.BR restorecon (8),
e58e94
 .BR fixfiles (8),
e58e94
+.BR restorecon (8),
e58e94
 .BR setfiles (8),
e58e94
 .BR semanage (8),
2f49e0
 .BR sepolicy (8)
2f49e0
+.BR seinfo (8),
2f49e0
+.BR sesearch (8)
e58e94
 
e58e94
 Every confined service on the system has a man page in the following format:
e58e94
 .br
f2f46e
diff --git libselinux-2.7/src/Makefile libselinux-2.7/src/Makefile
f2f46e
index 2408fae..18df75c 100644
f2f46e
--- libselinux-2.7/src/Makefile
f2f46e
+++ libselinux-2.7/src/Makefile
f2f46e
@@ -148,7 +148,7 @@ $(LIBSO): $(LOBJS)
f2f46e
 	ln -sf $@ $(TARGET)
f2f46e
 
f2f46e
 $(LIBPC): $(LIBPC).in ../VERSION
f2f46e
-	sed -e 's/@VERSION@/$(VERSION)/; s:@prefix@:$(PREFIX):; s:@libdir@:$(LIBBASE):; s:@includedir@:$(INCLUDEDIR):' < $< > $@
f2f46e
+	sed -e 's/@VERSION@/$(VERSION)/; s:@prefix@:$(PREFIX):; s:@libdir@:$(LIBBASE):; s:@includedir@:$(INCLUDEDIR):; s:@PCRE_MODULE@:$(PCRE_MODULE):' < $< > $@
f2f46e
 
f2f46e
 selinuxswig_python_exception.i: ../include/selinux/selinux.h
f2f46e
 	bash -e exception.sh > $@ || (rm -f $@ ; false)
f2f46e
diff --git libselinux-2.7/src/avc.c libselinux-2.7/src/avc.c
f2f46e
index 96b2678..5230efd 100644
f2f46e
--- libselinux-2.7/src/avc.c
f2f46e
+++ libselinux-2.7/src/avc.c
f2f46e
@@ -4,7 +4,7 @@
f2f46e
  * Author : Eamon Walsh <ewalsh@epoch.ncsc.mil>
f2f46e
  *
f2f46e
  * Derived from the kernel AVC implementation by
f2f46e
- * Stephen Smalley <sds@epoch.ncsc.mil> and 
f2f46e
+ * Stephen Smalley <sds@tycho.nsa.gov> and
f2f46e
  * James Morris <jmorris@redhat.com>.
f2f46e
  */
f2f46e
 #include <selinux avc.h="">
2f49e0
diff --git libselinux-2.7/src/avc_sidtab.c libselinux-2.7/src/avc_sidtab.c
e58e94
index 9669264..c775430 100644
2f49e0
--- libselinux-2.7/src/avc_sidtab.c
2f49e0
+++ libselinux-2.7/src/avc_sidtab.c
e58e94
@@ -81,6 +81,11 @@ sidtab_context_to_sid(struct sidtab *s,
e58e94
 	int hvalue, rc = 0;
e58e94
 	struct sidtab_node *cur;
e58e94
 
e58e94
+	if (! ctx) {
e58e94
+		errno=EINVAL;
e58e94
+		return -1;
e58e94
+	}
e58e94
+
e58e94
 	*sid = NULL;
e58e94
 	hvalue = sidtab_hash(ctx);
e58e94
 
2f49e0
diff --git libselinux-2.7/src/booleans.c libselinux-2.7/src/booleans.c
2f49e0
index 1da55bf..604c588 100644
2f49e0
--- libselinux-2.7/src/booleans.c
2f49e0
+++ libselinux-2.7/src/booleans.c
7f0ad3
@@ -55,6 +55,7 @@ int security_get_boolean_names(char ***names, int *len)
7f0ad3
 	snprintf(path, sizeof path, "%s%s", selinux_mnt, SELINUX_BOOL_DIR);
7f0ad3
 	*len = scandir(path, &namelist, &filename_select, alphasort);
7f0ad3
 	if (*len <= 0) {
7f0ad3
+		errno = ENOENT;
7f0ad3
 		return -1;
7f0ad3
 	}
7f0ad3
 
2f49e0
diff --git libselinux-2.7/src/canonicalize_context.c libselinux-2.7/src/canonicalize_context.c
2f49e0
index ba4c9a2..c815872 100644
2f49e0
--- libselinux-2.7/src/canonicalize_context.c
2f49e0
+++ libselinux-2.7/src/canonicalize_context.c
e58e94
@@ -17,6 +17,11 @@ int security_canonicalize_context_raw(const char * con,
e58e94
 	size_t size;
e58e94
 	int fd, ret;
e58e94
 
e58e94
+	if (! con) {
e58e94
+		errno=EINVAL;
e58e94
+		return -1;
e58e94
+	}
e58e94
+
e58e94
 	if (!selinux_mnt) {
e58e94
 		errno = ENOENT;
e58e94
 		return -1;
2f49e0
diff --git libselinux-2.7/src/check_context.c libselinux-2.7/src/check_context.c
2f49e0
index 8a7997f..5be8434 100644
2f49e0
--- libselinux-2.7/src/check_context.c
2f49e0
+++ libselinux-2.7/src/check_context.c
e58e94
@@ -14,6 +14,11 @@ int security_check_context_raw(const char * con)
e58e94
 	char path[PATH_MAX];
e58e94
 	int fd, ret;
e58e94
 
e58e94
+	if (! con) {
e58e94
+		errno=EINVAL;
e58e94
+		return -1;
e58e94
+	}
e58e94
+
e58e94
 	if (!selinux_mnt) {
e58e94
 		errno = ENOENT;
e58e94
 		return -1;
2f49e0
diff --git libselinux-2.7/src/compute_av.c libselinux-2.7/src/compute_av.c
2f49e0
index 1d05e7b..d9095cc 100644
2f49e0
--- libselinux-2.7/src/compute_av.c
2f49e0
+++ libselinux-2.7/src/compute_av.c
e58e94
@@ -26,6 +26,11 @@ int security_compute_av_flags_raw(const char * scon,
e58e94
 		return -1;
e58e94
 	}
e58e94
 
e58e94
+	if ((! scon) || (! tcon)) {
e58e94
+		errno=EINVAL;
e58e94
+		return -1;
e58e94
+	}
e58e94
+
e58e94
 	snprintf(path, sizeof path, "%s/access", selinux_mnt);
2f49e0
 	fd = open(path, O_RDWR | O_CLOEXEC);
e58e94
 	if (fd < 0)
2f49e0
diff --git libselinux-2.7/src/compute_create.c libselinux-2.7/src/compute_create.c
2f49e0
index 0975aea..3e6a48c 100644
2f49e0
--- libselinux-2.7/src/compute_create.c
2f49e0
+++ libselinux-2.7/src/compute_create.c
e58e94
@@ -64,6 +64,11 @@ int security_compute_create_name_raw(const char * scon,
e58e94
 		return -1;
e58e94
 	}
e58e94
 
e58e94
+	if ((! scon) || (! tcon)) {
e58e94
+		errno=EINVAL;
e58e94
+		return -1;
e58e94
+	}
e58e94
+
e58e94
 	snprintf(path, sizeof path, "%s/create", selinux_mnt);
2f49e0
 	fd = open(path, O_RDWR | O_CLOEXEC);
e58e94
 	if (fd < 0)
2f49e0
diff --git libselinux-2.7/src/compute_member.c libselinux-2.7/src/compute_member.c
2f49e0
index 4e2d221..d1dd977 100644
2f49e0
--- libselinux-2.7/src/compute_member.c
2f49e0
+++ libselinux-2.7/src/compute_member.c
e58e94
@@ -25,6 +25,11 @@ int security_compute_member_raw(const char * scon,
e58e94
 		return -1;
e58e94
 	}
e58e94
 
e58e94
+	if ((! scon) || (! tcon)) {
e58e94
+		errno=EINVAL;
e58e94
+		return -1;
e58e94
+	}
e58e94
+
e58e94
 	snprintf(path, sizeof path, "%s/member", selinux_mnt);
2f49e0
 	fd = open(path, O_RDWR | O_CLOEXEC);
e58e94
 	if (fd < 0)
2f49e0
diff --git libselinux-2.7/src/compute_relabel.c libselinux-2.7/src/compute_relabel.c
2f49e0
index 49f77ef..c3db7c0 100644
2f49e0
--- libselinux-2.7/src/compute_relabel.c
2f49e0
+++ libselinux-2.7/src/compute_relabel.c
e58e94
@@ -25,6 +25,11 @@ int security_compute_relabel_raw(const char * scon,
e58e94
 		return -1;
e58e94
 	}
e58e94
 
e58e94
+	if ((! scon) || (! tcon)) {
e58e94
+		errno=EINVAL;
e58e94
+		return -1;
e58e94
+	}
e58e94
+
e58e94
 	snprintf(path, sizeof path, "%s/relabel", selinux_mnt);
2f49e0
 	fd = open(path, O_RDWR | O_CLOEXEC);
e58e94
 	if (fd < 0)
2f49e0
diff --git libselinux-2.7/src/compute_user.c libselinux-2.7/src/compute_user.c
2f49e0
index 7b88121..401fd10 100644
2f49e0
--- libselinux-2.7/src/compute_user.c
2f49e0
+++ libselinux-2.7/src/compute_user.c
e58e94
@@ -24,6 +24,11 @@ int security_compute_user_raw(const char * scon,
e58e94
 		return -1;
e58e94
 	}
e58e94
 
e58e94
+	if (! scon) {
e58e94
+		errno=EINVAL;
e58e94
+		return -1;
e58e94
+	}
e58e94
+
e58e94
 	snprintf(path, sizeof path, "%s/user", selinux_mnt);
2f49e0
 	fd = open(path, O_RDWR | O_CLOEXEC);
e58e94
 	if (fd < 0)
2f49e0
diff --git libselinux-2.7/src/fsetfilecon.c libselinux-2.7/src/fsetfilecon.c
e58e94
index 52707d0..0cbe12d 100644
2f49e0
--- libselinux-2.7/src/fsetfilecon.c
2f49e0
+++ libselinux-2.7/src/fsetfilecon.c
e58e94
@@ -9,8 +9,12 @@
e58e94
 
e58e94
 int fsetfilecon_raw(int fd, const char * context)
e58e94
 {
e58e94
-	int rc = fsetxattr(fd, XATTR_NAME_SELINUX, context, strlen(context) + 1,
e58e94
-			 0);
e58e94
+	int rc;
e58e94
+	if (! context) {
e58e94
+		errno=EINVAL;
e58e94
+		return -1;
e58e94
+	}
e58e94
+	rc = fsetxattr(fd, XATTR_NAME_SELINUX, context, strlen(context) + 1, 0);
e58e94
 	if (rc < 0 && errno == ENOTSUP) {
e58e94
 		char * ccontext = NULL;
e58e94
 		int err = errno;
f2f46e
diff --git libselinux-2.7/src/libselinux.pc.in libselinux-2.7/src/libselinux.pc.in
f2f46e
index 2cd04d3..2e90a84 100644
f2f46e
--- libselinux-2.7/src/libselinux.pc.in
f2f46e
+++ libselinux-2.7/src/libselinux.pc.in
f2f46e
@@ -7,6 +7,6 @@ Name: libselinux
f2f46e
 Description: SELinux utility library
f2f46e
 Version: @VERSION@
f2f46e
 URL: http://userspace.selinuxproject.org/
f2f46e
-Requires.private: libsepol libpcre
f2f46e
+Requires.private: libsepol @PCRE_MODULE@
f2f46e
 Libs: -L${libdir} -lselinux
f2f46e
 Cflags: -I${includedir}
2f49e0
diff --git libselinux-2.7/src/lsetfilecon.c libselinux-2.7/src/lsetfilecon.c
e58e94
index 1d3b28a..ea6d70b 100644
2f49e0
--- libselinux-2.7/src/lsetfilecon.c
2f49e0
+++ libselinux-2.7/src/lsetfilecon.c
e58e94
@@ -9,8 +9,13 @@
e58e94
 
e58e94
 int lsetfilecon_raw(const char *path, const char * context)
e58e94
 {
e58e94
-	int rc = lsetxattr(path, XATTR_NAME_SELINUX, context, strlen(context) + 1,
e58e94
-			 0);
e58e94
+	int rc;
e58e94
+	if (! context) {
e58e94
+		errno=EINVAL;
e58e94
+		return -1;
e58e94
+	}
e58e94
+
e58e94
+	rc = lsetxattr(path, XATTR_NAME_SELINUX, context, strlen(context) + 1, 0);
e58e94
 	if (rc < 0 && errno == ENOTSUP) {
e58e94
 		char * ccontext = NULL;
e58e94
 		int err = errno;
2f49e0
diff --git libselinux-2.7/src/setfilecon.c libselinux-2.7/src/setfilecon.c
e58e94
index d05969c..3f0200e 100644
2f49e0
--- libselinux-2.7/src/setfilecon.c
2f49e0
+++ libselinux-2.7/src/setfilecon.c
e58e94
@@ -9,8 +9,12 @@
e58e94
 
e58e94
 int setfilecon_raw(const char *path, const char * context)
e58e94
 {
e58e94
-	int rc = setxattr(path, XATTR_NAME_SELINUX, context, strlen(context) + 1,
e58e94
-			0);
e58e94
+	int rc;
e58e94
+	if (! context) {
e58e94
+		errno=EINVAL;
e58e94
+		return -1;
e58e94
+	}
e58e94
+	rc = setxattr(path, XATTR_NAME_SELINUX, context, strlen(context) + 1, 0);
e58e94
 	if (rc < 0 && errno == ENOTSUP) {
e58e94
 		char * ccontext = NULL;
e58e94
 		int err = errno;
2f49e0
diff --git libselinux-2.7/utils/matchpathcon.c libselinux-2.7/utils/matchpathcon.c
2f49e0
index 67e4a43..9756d7d 100644
2f49e0
--- libselinux-2.7/utils/matchpathcon.c
2f49e0
+++ libselinux-2.7/utils/matchpathcon.c
2f49e0
@@ -14,7 +14,7 @@
2f49e0
 static __attribute__ ((__noreturn__)) void usage(const char *progname)
7f0ad3
 {
7f0ad3
 	fprintf(stderr,
7f0ad3
-		"usage:  %s [-N] [-n] [-f file_contexts] [ -P policy_root_path ] [-p prefix] [-Vq] path...\n",
7f0ad3
+		"usage:  %s [-V] [-N] [-n] [-m type] [-f file_contexts_file] [-p prefix] [-P policy_root_path] filepath...\n",
7f0ad3
 		progname);
7f0ad3
 	exit(1);
7f0ad3
 }