Skip to contentSkip to conversation

libselinux - Remove assert in security_get_boolean_names(3)

PATCH Applied Richard Haines 2 participants 2 messages Nov 27, 2011 – Dec 1, 2011 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libselinux - Remove assert in security_get_boolean_names(3)

Remove assert in security_get_boolean_names(3) if the len invalid and stop seg fault if names is null. Set EINVAL instead and return error.

---
 libselinux/src/booleans.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
libselinux/src/booleans.c +4 -2
index bbf8324..1510043 100644
@@ -8,7 +8,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#include <assert.h>
 #include <stdlib.h>
 #include <dirent.h>
 #include <string.h>
@@ -41,7 +40,10 @@ int security_get_boolean_names(char ***names, int *len)
 	struct dirent **namelist;
 	char **n;
 
-	assert(len);
+	if (!len || names == NULL) {
+		errno = EINVAL;
+		return -1;
+	}
 	if (!selinux_mnt) {
 		errno = ENOENT;
 		return -1;
Signature · 10 lines
1.7.7.1





--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
Applied
#1 lore raw

applied to my devel branch

Quoted 38 lines · Richard Haines

Remove assert in security_get_boolean_names(3) if the len invalid and stop seg fault if names is null. Set EINVAL instead and return error.

---
 libselinux/src/booleans.c |    6 ++++--

 1 files changed, 4 insertions(+), 2 deletions(-)
libselinux/src/booleans.c +4 -3
index bbf8324..1510043 100644
@@ -8,7 +8,6 @@
  #include <sys/types.h>
  #include <sys/stat.h>
  #include <fcntl.h>
-#include <assert.h>
  #include <stdlib.h>
  #include <dirent.h>
  #include <string.h>
@@ -41,7 +40,10 @@ int security_get_boolean_names(char ***names, int *len)
        struct dirent **namelist;
        char **n;
 
-       assert(len);
+       if (!len || names == NULL) {
+               errno = EINVAL;
+               return -1;
+       }
        if (!selinux_mnt) {
                errno = ENOENT;
                return -1;
--

1.7.7.1

Quoted 4 lines

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.