]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib: simplify smbpasswd_sethexpwd() with hex_encode_buf()
authorVolker Lendecke <vl@samba.org>
Fri, 20 Sep 2024 13:17:33 +0000 (15:17 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 12 Nov 2024 12:09:34 +0000 (12:09 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source4/lib/samba3/smbpasswd.c

index 581c113e7c462aee9134cc6ea9ab076d364cd485..6f4d832ae2ba2a83da2b6a503261d599bb459d4f 100644 (file)
@@ -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");