mirror of
https://github.com/topjohnwu/selinux.git
synced 2025-02-01 08:52:09 +00:00
libselinux: make context_*_set() return -1 when an error occurs
In libselinux, most functions set errno and return -1 when an error occurs. But some functions return 1 instead, such as context_type_set(), context_role_set(), etc. This increases the difficulty of writing Python bindings of these functions without much benefit. Return -1 instead (errno was already set). Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
This commit is contained in:
parent
164f437b19
commit
091549b2d0
@ -151,14 +151,14 @@ static int set_comp(context_private_t * n, int idx, const char *str)
|
||||
if (str) {
|
||||
t = (char *)malloc(strlen(str) + 1);
|
||||
if (!t) {
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
for (p = str; *p; p++) {
|
||||
if (*p == '\t' || *p == '\n' || *p == '\r' ||
|
||||
((*p == ':' || *p == ' ') && idx != COMP_RANGE)) {
|
||||
free(t);
|
||||
errno = EINVAL;
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
strcpy(t, str);
|
||||
|
Loading…
x
Reference in New Issue
Block a user