libsepol: sepol_check_context correct error handling behavior
PATCH 1/1 libsepol: sepol_check_context correct error handling behavior
Returns EINVAL, EEXIST as appropriate. Also fixed man page.
---
man/man3/sepol_check_context.3 | 2 +- src/context.c | 1 + src/context_record.c | 2 ++ src/sidtab.c | 4 +++- 4 files changed, 7 insertions(+), 2 deletions(-)
src/sidtab.c +0 -0
@@ -56,8 +56,10 @@
cur = cur->next; }
- if (cur && sid == cur->sid)
+ if (cur && sid == cur->sid) {
+ errno = EEXIST; return -EEXIST;
+ }
newnode = (sidtab_node_t *) malloc(sizeof(sidtab_node_t)); if (newnode == NULL)
src/context_record.c +1 -0
@@ -1,3 +1,4 @@ +#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
@@ -260,6 +261,7 @@
return STATUS_SUCCESS;
mcontext:
+ errno = EINVAL;
ERR(handle, "malformed context \"%s\"", str);
err:src/context.c +0 -0
@@ -224,6 +224,7 @@
return STATUS_SUCCESS;
err_destroy:
+ errno = EINVAL;
context_destroy(scontext);
err:man/man3/sepol_check_context.3 +0 -0
@@ -22,4 +22,4 @@
from libselinux instead.
.SH "RETURN VALUE"
-Returns 0 on success or -EINVAL otherwise. +Returns 0 on success or -1 with errno set otherwise.
Signature · 8 lines
Eamon Walsh <[email protected]> National Security Agency -- 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.
Quoted 10 lines · Eamon Walsh
Returns EINVAL, EEXIST as appropriate. Also fixed man page.
Signed-off-by Eamon Walsh <[email protected]>---
man/man3/sepol_check_context.3 | 2 +- src/context.c | 1 + src/context_record.c | 2 ++ src/sidtab.c | 4 +++- 4 files changed, 7 insertions(+), 2 deletions(-)
Merge at will.
Quoted 60 lines
Index:
libsepol/src/sidtab.c
===================================================================src/sidtab.c +3
-1@@ -56,8 +56,10 @@ cur = cur->next; } -if (cur && sid == cur->sid) +if (cur && sid == cur->sid) { + errno =EEXIST ;return -EEXIST ; + } newnode = (sidtab_node_t *)malloc (sizeof (sidtab_node_t));if (newnode ==NULL )Index:
libsepol/src/context_record.c
===================================================================src/context_record.c +2
-0@@ -1,3 +1,4 @@ +#include <errno.h> #include <stdlib.h> #include <string.h> #include <stdio.h> @@ -260,6 +261,7 @@return STATUS_SUCCESS ; mcontext: + errno =EINVAL ;ERR (handle,"malformed context \"%s\"" , str); err:Index:
libsepol/src/context.c
===================================================================src/context.c +1
-0@@ -224,6 +224,7 @@return STATUS_SUCCESS ; err_destroy: + errno =EINVAL ;context_destroy (scontext); err:Index: libsepol/man/man3/sepol_check_context.3
===================================================================man/man3/sepol_check_context.3 +1
-1@@ -22,4 +22,4 @@ from libselinux instead. .SH "RETURN VALUE" -Returns 0 on success or -EINVAL otherwise. +Returns 0 on success or -1 with errno set otherwise.
Signature · 8 lines
Stephen Smalley National Security Agency -- 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.