From: Volker Lendecke Date: Fri, 20 Sep 2024 13:17:33 +0000 (+0200) Subject: lib: simplify smbpasswd_sethexpwd() with hex_encode_buf() X-Git-Tag: tdb-1.4.13~558 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=804568a1d7910e989a3630d43efd670c254d32ff;p=thirdparty%2Fsamba.git lib: simplify smbpasswd_sethexpwd() with hex_encode_buf() Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- 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");