diff options
-rw-r--r-- | src/gss_err.c | 21 | ||||
-rw-r--r-- | src/ntlm_common.h | 1 | ||||
-rw-r--r-- | tests/ntlmssptest.c | 15 |
3 files changed, 36 insertions, 1 deletions
diff --git a/src/gss_err.c b/src/gss_err.c index b350a19..ad2fcec 100644 --- a/src/gss_err.c +++ b/src/gss_err.c @@ -9,7 +9,18 @@ #include "gss_ntlmssp.h" -#define UNKNOWN_ERROR "Unknown Error" +/* Untl we get gettext support */ +#define _(x) x + +/* the order is determined by ntlm_err_code order */ +static const char *err_strs[] = { + _("Unknown Error"), + _("Failed to decode data"), /* ERR_DECODE */ + _("Failed to encode data"), /* ERR_ENCODE */ + _("Crypto routine failure"), /* ERR_CRYPTO */ +}; + +#define UNKNOWN_ERROR err_strs[0] uint32_t gssntlm_display_status(uint32_t *minor_status, uint32_t status_value, @@ -42,6 +53,14 @@ uint32_t gssntlm_display_status(uint32_t *minor_status, goto done; } + if (status_value > ERR_BASE && status_value < ERR_LAST) { + status_string->value = strdup(err_strs[status_value - ERR_BASE]); + if (!status_string->value) { + return GSSERRS(ENOMEM, GSS_S_FAILURE); + } + goto done; + } + /* handle both XSI and GNU specific varints of strerror_r */ errno = 0; #if ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE) diff --git a/src/ntlm_common.h b/src/ntlm_common.h index 24d12fb..5cfb36c 100644 --- a/src/ntlm_common.h +++ b/src/ntlm_common.h @@ -26,6 +26,7 @@ enum ntlm_err_code { ERR_DECODE, ERR_ENCODE, ERR_CRYPTO, + ERR_LAST }; #define NTLM_ERR_MASK 0x4E54FFFF #define IS_NTLM_ERR_CODE(x) (((x) & NTLM_ERR_MASK) ? true : false) diff --git a/tests/ntlmssptest.c b/tests/ntlmssptest.c index ddc9d75..e549c3b 100644 --- a/tests/ntlmssptest.c +++ b/tests/ntlmssptest.c @@ -1425,6 +1425,17 @@ static void print_min_status(uint32_t err) } while (msgctx); } +int test_Errors(void) +{ + int i; + for (i = ERR_BASE; i < ERR_LAST; i++) { + fprintf(stderr, "%x: ", i); + print_min_status(i); + fprintf(stderr, "\n"); + } + return 0; +} + static void print_gss_error(const char *text, uint32_t maj, uint32_t min) { @@ -1978,6 +1989,10 @@ int main(int argc, const char *argv[]) /* enable trace debugging by dfault in tests */ setenv("GSSNTLMSSP_DEBUG", "tests-trace.log", 0); + fprintf(stdout, "Test errors\n"); + ret = test_Errors(); + fprintf(stdout, "Test: %s\n", (ret ? "FAIL":"SUCCESS")); + ret = ntlm_init_ctx(&ctx); if (ret) goto done; |