libselinux: return EINVAL if invalid role selected

For get_default_context_with_role(3) and get_default_context_with_rolelevel(3),
return errno = EINVAL if invalid role.

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:
Richard Haines 2011-11-27 16:08:10 +00:00 committed by Eric Paris
parent 83161f73ea
commit aed37210a3
1 changed files with 3 additions and 1 deletions

View File

@ -38,8 +38,10 @@ int get_default_context_with_role(const char *user,
} }
rc = -1; rc = -1;
if (!(*ptr)) if (!(*ptr)) {
errno = EINVAL;
goto out; goto out;
}
*newcon = strdup(*ptr); *newcon = strdup(*ptr);
if (!(*newcon)) if (!(*newcon))
goto out; goto out;