summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgww <gww@eng.sun.com>2008-12-12 13:07:31 -0800
committergww <gww@eng.sun.com>2008-12-12 13:07:31 -0800
commita972924280e9420519267ece8fcddfb8fc29a96b (patch)
tree3007db391a7c725cb0e5851a1429a259d03ebaf4
parentf88604082ab7f434d64d4a9b92fdfe651e053a11 (diff)
downloadillumos-gate-a972924280e9420519267ece8fcddfb8fc29a96b.tar.gz
6624444 adt_put_event failure conditions should all be reviewed for a proper exit_error parameter use
-rw-r--r--usr/src/cmd/praudit/format.c41
1 files changed, 31 insertions, 10 deletions
diff --git a/usr/src/cmd/praudit/format.c b/usr/src/cmd/praudit/format.c
index 7958057f8a..c7342ad521 100644
--- a/usr/src/cmd/praudit/format.c
+++ b/usr/src/cmd/praudit/format.c
@@ -2628,7 +2628,20 @@ pa_error(const uchar_t err, char *buf, size_t buflen)
/*
* -----------------------------------------------------------------------
- * pa_retval() : convert the return token return value code.
+ * pa_retval() : convert the return token return value code.
+ *
+ * input : err, for kernel success 0, or
+ * failure errno: 0 > & < sys_nerr.
+ * for userland success ADT_SUCCESS (0) or
+ * failure ADT_FAILURE (-1).
+ * pa_error() above has already converted err.
+ *
+ * : retval, for kernel arbitrary return value for success, or
+ * failure: -1.
+ * for userland,
+ * >= ADT_FAIL_VALUE < ADT_FAIL_PAM, an adt message code;
+ * >= ADT_FAIL_PAM, a pam_strerror value;
+ * < ADT_FAIL_VALUE, supposed to be an errno.
*
* output : buf string representing return token error code.
*
@@ -2637,7 +2650,19 @@ pa_error(const uchar_t err, char *buf, size_t buflen)
void
pa_retval(const uchar_t err, const int32_t retval, char *buf, size_t buflen)
{
- struct msg_text *msglist = &adt_msg_text[ADT_LIST_FAIL_VALUE];
+ struct msg_text *msglist;
+ char *emsg;
+
+ /* success or kernel failure */
+ if (((char)err == ADT_SUCCESS) ||
+ (retval < 0)) {
+
+ (void) snprintf(buf, buflen, "%d", retval);
+ return;
+ }
+
+ /* userland failure */
+ msglist = &adt_msg_text[ADT_LIST_FAIL_VALUE];
if ((retval + msglist->ml_offset >= msglist->ml_min_index) &&
(retval + msglist->ml_offset <= msglist->ml_max_index)) {
@@ -2647,22 +2672,18 @@ pa_retval(const uchar_t err, const int32_t retval, char *buf, size_t buflen)
buflen);
} else if ((retval >= ADT_FAIL_PAM) &&
(retval < ADT_FAIL_PAM + PAM_TOTAL_ERRNUM)) {
+
(void) strlcpy(buf, pam_strerror(NULL, retval - ADT_FAIL_PAM),
buflen);
- } else if ((char)err == ADT_FAILURE) {
- char *emsg = strerror(retval);
+ } else if ((emsg = strerror(retval)) != NULL) {
- if (emsg != NULL) {
- (void) strlcpy(buf, emsg, buflen);
- } else {
- (void) snprintf(buf, buflen, "%d", retval);
- }
+ (void) strlcpy(buf, emsg, buflen);
} else {
+
(void) snprintf(buf, buflen, "%d", retval);
}
}
-
/*
* -----------------------------------------------------------------------
* pa_printstr() : print a given string, translating unprintables