mirror of
https://github.com/SELinuxProject/selinux
synced 2025-02-28 07:20:30 +00:00
libselinux: get_default_type now sets EINVAL if no entry.
get_default_type(3) now returns with errno set to EINVAL if the entry does not exist. Signed-off-by: Richard Haines <richard_c_haines@btinternet.com> Signed-off-by: Eric Paris <eparis@redhat.com> Acked-by: Dan Walsh <dwalsh@redhat.com>
This commit is contained in:
parent
d0a8d81882
commit
83161f73ea
@ -3,6 +3,7 @@
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "get_default_type_internal.h"
|
||||
#include <errno.h>
|
||||
|
||||
static int find_default_type(FILE * fp, const char *role, char **type);
|
||||
|
||||
@ -32,8 +33,10 @@ static int find_default_type(FILE * fp, const char *role, char **type)
|
||||
|
||||
len = strlen(role);
|
||||
while (!feof_unlocked(fp)) {
|
||||
if (!fgets_unlocked(buf, sizeof buf, fp))
|
||||
if (!fgets_unlocked(buf, sizeof buf, fp)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (buf[strlen(buf) - 1])
|
||||
buf[strlen(buf) - 1] = 0;
|
||||
|
||||
@ -53,8 +56,10 @@ static int find_default_type(FILE * fp, const char *role, char **type)
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
if (!found) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
t = malloc(strlen(buf) - len);
|
||||
if (!t)
|
||||
|
Loading…
Reference in New Issue
Block a user