diff options
author | Andreas Schneider <asn@samba.org> | 2019-05-29 15:50:45 +0200 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2019-07-26 01:48:24 +0000 |
commit | 576bcf61555fb641b2919ad84a6b26b242b57061 (patch) | |
tree | e671aee58735c352a45f7ab8d53e0f6e58648b87 /libcli | |
parent | 9ea736590d9b22a7518f86b18e8c55b0d0e213d5 (diff) | |
download | samba-576bcf61555fb641b2919ad84a6b26b242b57061.tar.gz |
libcli:auth: Return WERROR for encode_wkssvc_join_password_buffer()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14031
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'libcli')
-rw-r--r-- | libcli/auth/proto.h | 8 | ||||
-rw-r--r-- | libcli/auth/smbencrypt.c | 20 |
2 files changed, 18 insertions, 10 deletions
diff --git a/libcli/auth/proto.h b/libcli/auth/proto.h index 67caaca8c41..65ee06215dc 100644 --- a/libcli/auth/proto.h +++ b/libcli/auth/proto.h @@ -207,10 +207,10 @@ bool set_pw_in_buffer(uint8_t buffer[516], const DATA_BLOB *password); bool extract_pw_from_buffer(TALLOC_CTX *mem_ctx, uint8_t in_buffer[516], DATA_BLOB *new_pass); struct wkssvc_PasswordBuffer; -void encode_wkssvc_join_password_buffer(TALLOC_CTX *mem_ctx, - const char *pwd, - DATA_BLOB *session_key, - struct wkssvc_PasswordBuffer **pwd_buf); +WERROR encode_wkssvc_join_password_buffer(TALLOC_CTX *mem_ctx, + const char *pwd, + DATA_BLOB *session_key, + struct wkssvc_PasswordBuffer **pwd_buf); WERROR decode_wkssvc_join_password_buffer(TALLOC_CTX *mem_ctx, struct wkssvc_PasswordBuffer *pwd_buf, DATA_BLOB *session_key, diff --git a/libcli/auth/smbencrypt.c b/libcli/auth/smbencrypt.c index 793012553b2..745f47999cd 100644 --- a/libcli/auth/smbencrypt.c +++ b/libcli/auth/smbencrypt.c @@ -965,10 +965,10 @@ bool extract_pw_from_buffer(TALLOC_CTX *mem_ctx, * buffer), calling MD5Update() first with session_key and then with confounder * (vice versa in samr) - Guenther */ -void encode_wkssvc_join_password_buffer(TALLOC_CTX *mem_ctx, - const char *pwd, - DATA_BLOB *session_key, - struct wkssvc_PasswordBuffer **pwd_buf) +WERROR encode_wkssvc_join_password_buffer(TALLOC_CTX *mem_ctx, + const char *pwd, + DATA_BLOB *session_key, + struct wkssvc_PasswordBuffer **pwd_buf) { uint8_t buffer[516]; gnutls_hash_hd_t hash_hnd = NULL; @@ -976,11 +976,12 @@ void encode_wkssvc_join_password_buffer(TALLOC_CTX *mem_ctx, DATA_BLOB confounded_session_key; int confounder_len = 8; uint8_t confounder[8]; + WERROR werr; int rc; my_pwd_buf = talloc_zero(mem_ctx, struct wkssvc_PasswordBuffer); if (!my_pwd_buf) { - return; + return WERR_NOT_ENOUGH_MEMORY; } confounded_session_key = data_blob_talloc(mem_ctx, NULL, 16); @@ -991,17 +992,23 @@ void encode_wkssvc_join_password_buffer(TALLOC_CTX *mem_ctx, rc = gnutls_hash_init(&hash_hnd, GNUTLS_DIG_MD5); if (rc < 0) { + werr = gnutls_error_to_werror(rc, WERR_INTERNAL_ERROR); + goto out; } rc = gnutls_hash(hash_hnd, session_key->data, session_key->length); if (rc < 0) { gnutls_hash_deinit(hash_hnd, NULL); + werr = gnutls_error_to_werror(rc, WERR_INTERNAL_ERROR); + goto out; } rc = gnutls_hash(hash_hnd, confounder, confounder_len); if (rc < 0) { gnutls_hash_deinit(hash_hnd, NULL); + werr = gnutls_error_to_werror(rc, WERR_INTERNAL_ERROR); + goto out; } gnutls_hash_deinit(hash_hnd, confounded_session_key.data); @@ -1017,8 +1024,9 @@ void encode_wkssvc_join_password_buffer(TALLOC_CTX *mem_ctx, *pwd_buf = my_pwd_buf; + werr = WERR_OK; out: - return; + return werr; } WERROR decode_wkssvc_join_password_buffer(TALLOC_CTX *mem_ctx, |