aboutsummaryrefslogtreecommitdiff
path: root/lib/tar/pax_header.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-11-16 15:41:57 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-11-18 00:58:07 +0100
commitda6eadc840716eb29b0175f39b2790bba166db4a (patch)
tree2da0a94126432e7af409ed809ea3476a1e44597c /lib/tar/pax_header.c
parent0f68ca18f491b4e53cec788b327a752cbeb43377 (diff)
Add a single, central hex blob decoder
Since we need it twice (once for tar, once for the filemap xattr parser), add a single, central implementation to libutil, add a unit test for that implementation and then use it in both libtar and gensquashfs. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/tar/pax_header.c')
-rw-r--r--lib/tar/pax_header.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/lib/tar/pax_header.c b/lib/tar/pax_header.c
index 8a1b077..cc2f2b0 100644
--- a/lib/tar/pax_header.c
+++ b/lib/tar/pax_header.c
@@ -26,15 +26,6 @@ static sqfs_u8 base64_convert(char in)
return 0;
}
-static int xdigit(int x)
-{
- if (isupper(x))
- return x - 'A' + 0x0A;
- if (islower(x))
- return x - 'a' + 0x0A;
- return x - '0';
-}
-
static size_t base64_decode(sqfs_u8 *out, const char *in, size_t len)
{
sqfs_u8 *start = out;
@@ -91,14 +82,13 @@ static void urldecode(char *str)
{
unsigned char *out = (unsigned char *)str;
char *in = str;
- int x;
while (*in != '\0') {
- x = *(in++);
+ sqfs_u8 x = *(in++);
if (x == '%' && isxdigit(in[0]) && isxdigit(in[1])) {
- x = xdigit(*(in++)) << 4;
- x |= xdigit(*(in++));
+ hex_decode(in, 2, &x, 1);
+ in += 2;
}
*(out++) = x;