diff options
author | Volker Lendecke <vl@samba.org> | 2021-01-04 13:52:48 +0100 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2021-01-08 20:31:33 +0000 |
commit | fd056127944182bf1fa96d025a4418d9c05d1982 (patch) | |
tree | a77caafc3fb694545e458e5508bcd28e50aa2a5c /lib/tdb | |
parent | ad081bf2ddb60dfd5b8f838741e9de0710598b6a (diff) | |
download | samba-fd056127944182bf1fa96d025a4418d9c05d1982.tar.gz |
tdb: Use hex_byte() in parse_hex()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib/tdb')
-rw-r--r-- | lib/tdb/tools/tdbtool.c | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/lib/tdb/tools/tdbtool.c b/lib/tdb/tools/tdbtool.c index 36e480cd29c..fca28a16ba8 100644 --- a/lib/tdb/tools/tdbtool.c +++ b/lib/tdb/tools/tdbtool.c @@ -349,23 +349,6 @@ static void store_tdb(char *keyname, size_t keylen, char* data, size_t datalen) } } -static bool hexchar(char c, uint8_t *v) -{ - if ((c >= '0') && (c <= '9')) { - *v = (c - '0'); - return true; - } - if ((c >= 'A') && (c <= 'F')) { - *v = (c - 'A' + 10); - return true; - } - if ((c >= 'a') && (c <= 'f')) { - *v = (c - 'a' + 10); - return true; - } - return false; -} - static bool parse_hex(const char *src, size_t srclen, uint8_t *dst) { size_t i=0; @@ -375,14 +358,11 @@ static bool parse_hex(const char *src, size_t srclen, uint8_t *dst) } while (i<srclen) { - bool ok; - uint8_t hi,lo; - - ok = (hexchar(src[i++], &hi) && hexchar(src[i++], &lo)); + bool ok = hex_byte(src, dst); if (!ok) { return false; } - *dst = (hi<<4)|lo; + src += 2; dst += 1; } |