]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
passdb: Simplify pdb_gethexhours() with hex_byte()
authorVolker Lendecke <vl@samba.org>
Tue, 10 Sep 2024 06:55:16 +0000 (08:55 +0200)
committerVolker Lendecke <vl@samba.org>
Fri, 20 Sep 2024 17:13:37 +0000 (17:13 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
source3/passdb/passdb.c

index 17b4b1d9dd4867c4e6a95f930ea1bd29f48e46f3..f0ce8b2352dc8ca4db99c6a37612946745e0c851 100644 (file)
@@ -470,29 +470,16 @@ void pdb_sethexhours(char *p, const unsigned char *hours)
 bool pdb_gethexhours(const char *p, unsigned char *hours)
 {
        int i;
-       unsigned char   lonybble, hinybble;
-       const char      *hexchars = "0123456789ABCDEF";
-       char           *p1, *p2;
 
        if (!p) {
                return (False);
        }
 
        for (i = 0; i < 42; i += 2) {
-               hinybble = toupper_m(p[i]);
-               lonybble = toupper_m(p[i + 1]);
-
-               p1 = strchr(hexchars, hinybble);
-               p2 = strchr(hexchars, lonybble);
-
-               if (!p1 || !p2) {
-                       return (False);
+               bool ok = hex_byte(p, (uint8_t *)&hours[i / 2]);
+               if (!ok) {
+                       return false;
                }
-
-               hinybble = PTR_DIFF(p1, hexchars);
-               lonybble = PTR_DIFF(p2, hexchars);
-
-               hours[i / 2] = (hinybble << 4) | lonybble;
        }
        return (True);
 }