From 804568a1d7910e989a3630d43efd670c254d32ff Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 20 Sep 2024 15:17:33 +0200 Subject: [PATCH] lib: simplify smbpasswd_sethexpwd() with hex_encode_buf() Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- source4/lib/samba3/smbpasswd.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/source4/lib/samba3/smbpasswd.c b/source4/lib/samba3/smbpasswd.c index 581c113e7c4..6f4d832ae2b 100644 --- a/source4/lib/samba3/smbpasswd.c +++ b/source4/lib/samba3/smbpasswd.c @@ -89,14 +89,11 @@ char *smbpasswd_sethexpwd(TALLOC_CTX *mem_ctx, struct samr_Password *pwd, uint16 { char *p; if (pwd != NULL) { - int i; p = talloc_array(mem_ctx, char, 33); if (!p) { return NULL; } - - for (i = 0; i < sizeof(pwd->hash); i++) - slprintf(&p[i*2], 3, "%02X", pwd->hash[i]); + hex_encode_buf(p, pwd->hash, sizeof(pwd->hash)); } else { if (acb_info & ACB_PWNOTREQ) p = talloc_strdup(mem_ctx, "NO PASSWORDXXXXXXXXXXXXXXXXXXXXX");