1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

vfs: Simplify capdecode() with hex_byte()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
This commit is contained in:
Volker Lendecke 2024-09-10 09:59:54 +02:00
parent 4803e85d7d
commit 9c22cee9d0

View File

@ -901,30 +901,8 @@ NTSTATUS vfs_cap_init(TALLOC_CTX *ctx)
/* For CAP functions */ /* For CAP functions */
#define hex_tag ':' #define hex_tag ':'
#define hex2bin(c) hex2bin_table[(unsigned char)(c)]
#define is_hex(s) ((s)[0] == hex_tag) #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 original code -> ":xx" - CAP format
********************************************************************/ ********************************************************************/
@ -993,7 +971,7 @@ static char *capdecode(TALLOC_CTX *ctx, const char *from)
for (out = to; *from;) { for (out = to; *from;) {
if (is_hex(from)) { if (is_hex(from)) {
*out++ = (hex2bin(from[1])<<4) | (hex2bin(from[2])); (void)hex_byte(&from[1], (uint8_t *)(out++));
from += 3; from += 3;
} else { } else {
*out++ = *from++; *out++ = *from++;