]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libsmb: Simplify pdb_sethexpwd with hex_byte()
authorVolker Lendecke <vl@samba.org>
Sun, 25 Aug 2024 10:08:49 +0000 (12:08 +0200)
committerVolker Lendecke <vl@samba.org>
Tue, 27 Aug 2024 07:19:32 +0000 (07:19 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jennifer Sutton <jsutton@samba.org>
source3/passdb/passdb.c

index 4bc48f63ee8cdf1cf1b0c3cfc8fd3d911c5474c7..17b4b1d9dd4867c4e6a95f930ea1bd29f48e46f3 100644 (file)
@@ -436,27 +436,15 @@ void pdb_sethexpwd(char p[33], const unsigned char *pwd, uint32_t acct_ctrl)
 bool pdb_gethexpwd(const char *p, unsigned char *pwd)
 {
        int i;
-       unsigned char   lonybble, hinybble;
-       const char      *hexchars = "0123456789ABCDEF";
-       char           *p1, *p2;
 
        if (!p)
                return false;
 
        for (i = 0; i < 32; i += 2) {
-               hinybble = toupper_m(p[i]);
-               lonybble = toupper_m(p[i + 1]);
-
-               p1 = strchr(hexchars, hinybble);
-               p2 = strchr(hexchars, lonybble);
-
-               if (!p1 || !p2)
+               bool ok = hex_byte(p + i, &pwd[i / 2]);
+               if (!ok) {
                        return false;
-
-               hinybble = PTR_DIFF(p1, hexchars);
-               lonybble = PTR_DIFF(p2, hexchars);
-
-               pwd[i / 2] = (hinybble << 4) | lonybble;
+               }
        }
        return true;
 }