[7.6] 0a76ab174 vmod_blob: Account for NUL to simplify alphabet initialization
Walid Boudebouda
walid.boudebouda at gmail.com
Mon May 12 15:29:05 UTC 2025
commit 0a76ab174f10c210e2c0544c935b696d5e3ac244
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Wed Mar 19 16:31:23 2025 +0100
vmod_blob: Account for NUL to simplify alphabet initialization
Alphabets for base64 and hex are 64 and 16 bytes long, respectively, but
initializing them with a string needs one additional byte for the final NUL.
Fixes #4300
diff --git a/vmod/vmod_blob.h b/vmod/vmod_blob.h
index 90872b61a..f775dd6c9 100644
--- a/vmod/vmod_blob.h
+++ b/vmod/vmod_blob.h
@@ -140,7 +140,7 @@ len_f hex_decode_l;
encode_f hex_encode;
decode_f hex_decode;
-extern const char hex_alphabet[][16];
+extern const char hex_alphabet[][17];
extern const uint8_t hex_nibble[];
/* url.c */
diff --git a/vmod/vmod_blob_base64.c b/vmod/vmod_blob_base64.c
index 74a895754..971a05e91 100644
--- a/vmod/vmod_blob_base64.c
+++ b/vmod/vmod_blob_base64.c
@@ -37,7 +37,7 @@
#include "vmod_blob.h"
static const struct b64_alphabet {
- const char b64[64];
+ const char b64[65];
const int8_t i64[256];
const int padding;
} b64_alphabet[] = {
diff --git a/vmod/vmod_blob_hex.c b/vmod/vmod_blob_hex.c
index 539ab87a7..b11701940 100644
--- a/vmod/vmod_blob_hex.c
+++ b/vmod/vmod_blob_hex.c
@@ -38,7 +38,7 @@
#include "vmod_blob.h"
-const char hex_alphabet[][16] = {
+const char hex_alphabet[][17] = {
"0123456789abcdef",
"0123456789ABCDEF"
};
More information about the varnish-commit
mailing list