]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs: Simplify capdecode() with hex_byte()
authorVolker Lendecke <vl@samba.org>
Tue, 10 Sep 2024 07:59:54 +0000 (09:59 +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/modules/vfs_cap.c

index 8d5eb6fc91e9bb9515b172fa60bf0a5dd35081bc..2d4ea76bb78af986742f97e2e3cf76816cd208b2 100644 (file)
@@ -901,30 +901,8 @@ NTSTATUS vfs_cap_init(TALLOC_CTX *ctx)
 
 /* For CAP functions */
 #define hex_tag ':'
-#define hex2bin(c)             hex2bin_table[(unsigned char)(c)]
 #define is_hex(s)              ((s)[0] == hex_tag)
 
-static unsigned char hex2bin_table[256] = {
-0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00 */
-0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10 */
-0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20 */
-0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, /* 0x30 */
-0000, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0000, /* 0x40 */
-0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000,
-0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x50 */
-0000, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0000, /* 0x60 */
-0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000,
-0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70 */
-0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x80 */
-0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x90 */
-0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xa0 */
-0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xb0 */
-0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xc0 */
-0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xd0 */
-0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xe0 */
-0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0  /* 0xf0 */
-};
-
 /*******************************************************************
   original code -> ":xx"  - CAP format
 ********************************************************************/
@@ -993,7 +971,7 @@ static char *capdecode(TALLOC_CTX *ctx, const char *from)
 
        for (out = to; *from;) {
                if (is_hex(from)) {
-                       *out++ = (hex2bin(from[1])<<4) | (hex2bin(from[2]));
+                       (void)hex_byte(&from[1], (uint8_t *)(out++));
                        from += 3;
                } else {
                        *out++ = *from++;