[6.0] 375afc077 vmod_blob: Account for NUL to simplify alphabet initialization

Walid Boudebouda walid.boudebouda at gmail.com
Wed Dec 10 15:43:07 UTC 2025


commit 375afc0779623e578b9e37768638dc2c3c954a6f
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
    
    Conflicts:
            lib/libvmod_blob/vmod_blob.h

diff --git a/lib/libvmod_blob/base64.h b/lib/libvmod_blob/base64.h
index 962ae22cd..7e30e1e78 100644
--- a/lib/libvmod_blob/base64.h
+++ b/lib/libvmod_blob/base64.h
@@ -32,7 +32,7 @@
 #define PAD ((int8_t) 126)
 
 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/lib/libvmod_blob/hex.c b/lib/libvmod_blob/hex.c
index adcf94b24..c14c5f4fd 100644
--- a/lib/libvmod_blob/hex.c
+++ b/lib/libvmod_blob/hex.c
@@ -38,7 +38,7 @@
 
 #include "vmod_blob.h"
 
-const char hex_alphabet[][16] = {
+const char hex_alphabet[][17] = {
 	"0123456789abcdef",
 	"0123456789ABCDEF"
 };
diff --git a/lib/libvmod_blob/hex.h b/lib/libvmod_blob/hex.h
index 53cfc8915..1f529a63c 100644
--- a/lib/libvmod_blob/hex.h
+++ b/lib/libvmod_blob/hex.h
@@ -32,6 +32,6 @@
 
 /* These are defined in hex.c */
 
-extern const char hex_alphabet[][16];
+extern const char hex_alphabet[][17];
 
 extern const uint8_t nibble[];



More information about the varnish-commit mailing list