libselinux: set errno in string functions
PATCH 1/1 libselinux: set errno in string functions
Set errno to EINVAL in string functions on bad input.
Signed-off-by Eamon Walsh <[email protected]>
---
stringrep.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
src/stringrep.c +0 -0
@@ -160,6 +160,7 @@
} }
+ errno = EINVAL; return 0; }
@@ -197,13 +198,17 @@
return av_perm_to_string[i].value; }
+ errno = EINVAL; return 0; }
const char *security_class_to_string(security_class_t tclass) {
- tclass = (tclass > 0 && tclass < NCLASSES) ? tclass : 0;
- return class_to_string_data.str + class_to_string[tclass];
+ if (tclass > 0 && tclass < NCLASSES)
+ return class_to_string_data.str + class_to_string[tclass];
+
+ errno = EINVAL;
+ return NULL;
}
const char *security_av_perm_to_string(security_class_t tclass, @@ -242,6 +247,7 @@
+ av_perm_to_string[i].nameidx; }
+ errno = EINVAL; return NULL; }
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 3 lines · Eamon Walsh
Set errno to EINVAL in string functions on bad input.
Signed-off-by Eamon Walsh <[email protected]>
Acked-by Stephen Smalley <[email protected]>
Merge at will.
Quoted 47 lines
---
stringrep.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)src/stringrep.c +8
-2@@ -160,6 +160,7 @@ } } + errno =EINVAL ;return 0 ; }@@ -197,13 +198,17 @@return av_perm_to_string[i].value; } + errno =EINVAL ;return 0 ; }const char *security_class_to_string (security_class_t tclass) { - tclass = (tclass >0 && tclass <NCLASSES ) ? tclass :0 ; -return class_to_string_data.str + class_to_string[tclass]; +if (tclass >0 && tclass <NCLASSES ) +return class_to_string_data.str + class_to_string[tclass]; + + errno =EINVAL ; +return NULL ; } const char *security_av_perm_to_string(security_class_t tclass,@@ -242,6 +247,7 @@ + av_perm_to_string[i].nameidx; } + errno =EINVAL ;return NULL ; }
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.