>From 1de0d6b7da5d48bef94f97948369bda4987998e3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 10 Dec 2012 13:22:10 -0800 Subject: [PATCH] Tidy up some of the API confusion in create_token_from_XXX() calls. Based on Michaels example, split out the return of NT_STATUS_NO_MEMORY on talloc fail from other possible errors. Allow the NTSTATUS return to be the only valid indication of success in these calls. Signed-off-by: Jeremy Allison --- source3/auth/token_util.c | 15 +++++++++------ 1 files changed, 9 insertions(+), 6 deletions(-) diff --git a/source3/auth/token_util.c b/source3/auth/token_util.c index 6f4bce0..38e1802 100644 --- a/source3/auth/token_util.c +++ b/source3/auth/token_util.c @@ -837,16 +837,19 @@ NTSTATUS create_token_from_username(TALLOC_CTX *mem_ctx, const char *username, goto done; } + /* + * If result == NT_STATUS_OK then + * we know we have a valid token. Ensure + * we also have a valid username to match. + */ + if (*found_username == NULL) { *found_username = talloc_strdup(mem_ctx, username); + if (*found_username == NULL) { + result = NT_STATUS_NO_MEMORY; + } } - if ((*token == NULL) || (*found_username == NULL)) { - result = NT_STATUS_NO_MEMORY; - goto done; - } - - result = NT_STATUS_OK; done: TALLOC_FREE(tmp_ctx); return result; -- 1.7.7.3