From 1cdb9605b5d22b5f34889e090fe94e3bc019416e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 25 Aug 2024 12:08:49 +0200 Subject: [PATCH] libsmb: Simplify pdb_sethexpwd with hex_byte() Signed-off-by: Volker Lendecke Reviewed-by: Jennifer Sutton --- source3/passdb/passdb.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c index 4bc48f63ee8..17b4b1d9dd4 100644 --- a/source3/passdb/passdb.c +++ b/source3/passdb/passdb.c @@ -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; } -- 2.47.3