base64: fix -Wunterminated-string-initialization warnings
What changed, and why it matters
This commit changes how two fixed lookup tables are written in the source code for the base64 encoding/decoding module. The old form used long string literals made of many hex escape characters; the new form lists individual characters/bytes inside braces. The commit message says the purpose is to silence a compiler warning about unterminated string initialization. The data values in the tables are identical before and after, so this is a code-style/maintenance change, not a security fix.
No security action required. Treat as a normal build-warning cleanup commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors the definition of base64_maps_rfc4648 in src/ccan/ccan/base64/base64.c. It replaces string-literal initializers for the encoding and decoding maps with braced aggregate initializers of char constants. The encoded map still contains the 64 RFC 4648 characters in order, and the decoded map still maps ASCII code points 0-255 to their 6-bit values (or 0xff for invalid characters). No functional behavior of base64_encode, base64_decode, or related functions is altered. The change only addresses -Wunterminated-string-initialization diagnostics from GCC.
Changed components
src/ccan/ccan/base64/base64.cInspect captured patch +62 / −40
diff --git a/src/ccan/ccan/base64/base64.c b/src/ccan/ccan/base64/base64.c
index 439655d..ea2ce87 100644
--- a/src/ccan/ccan/base64/base64.c
+++ b/src/ccan/ccan/base64/base64.c
@@ -214,44 +214,66 @@ ssize_t base64_decode_using_maps(const base64_maps_t *maps,
* base64_maps_rfc4648 - pregenerated maps struct for rfc4648
*/
const base64_maps_t base64_maps_rfc4648 = {
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
-
- "\xff\xff\xff\xff\xff" /* 0 */ \
- "\xff\xff\xff\xff\xff" /* 5 */ \
- "\xff\xff\xff\xff\xff" /* 10 */ \
- "\xff\xff\xff\xff\xff" /* 15 */ \
- "\xff\xff\xff\xff\xff" /* 20 */ \
- "\xff\xff\xff\xff\xff" /* 25 */ \
- "\xff\xff\xff\xff\xff" /* 30 */ \
- "\xff\xff\xff\xff\xff" /* 35 */ \
- "\xff\xff\xff\x3e\xff" /* 40 */ \
- "\xff\xff\x3f\x34\x35" /* 45 */ \
- "\x36\x37\x38\x39\x3a" /* 50 */ \
- "\x3b\x3c\x3d\xff\xff" /* 55 */ \
- "\xff\xff\xff\xff\xff" /* 60 */ \
- "\x00\x01\x02\x03\x04" /* 65 A */ \
- "\x05\x06\x07\x08\x09" /* 70 */ \
- "\x0a\x0b\x0c\x0d\x0e" /* 75 */ \
- "\x0f\x10\x11\x12\x13" /* 80 */ \
- "\x14\x15\x16\x17\x18" /* 85 */ \
- "\x19\xff\xff\xff\xff" /* 90 */ \
- "\xff\xff\x1a\x1b\x1c" /* 95 */ \
- "\x1d\x1e\x1f\x20\x21" /* 100 */ \
- "\x22\x23\x24\x25\x26" /* 105 */ \
- "\x27\x28\x29\x2a\x2b" /* 110 */ \
- "\x2c\x2d\x2e\x2f\x30" /* 115 */ \
- "\x31\x32\x33\xff\xff" /* 120 */ \
- "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" /* 125 */ \
- "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" \
- "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" \
- "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" /* 155 */ \
- "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" \
- "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" \
- "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" /* 185 */ \
- "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" \
- "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" \
- "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" /* 215 */ \
- "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" \
- "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" \
- "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" /* 245 */
+ {
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
+ 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
+ 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
+ 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
+ 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
+ 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
+ 'w', 'x', 'y', 'z', '0', '1', '2', '3',
+ '4', '5', '6', '7', '8', '9', '+', '/'
+ }, {
+ '\xff', '\xff', '\xff', '\xff', '\xff', /* 0 */
+ '\xff', '\xff', '\xff', '\xff', '\xff', /* 5 */
+ '\xff', '\xff', '\xff', '\xff', '\xff', /* 10 */
+ '\xff', '\xff', '\xff', '\xff', '\xff', /* 15 */
+ '\xff', '\xff', '\xff', '\xff', '\xff', /* 20 */
+ '\xff', '\xff', '\xff', '\xff', '\xff', /* 25 */
+ '\xff', '\xff', '\xff', '\xff', '\xff', /* 30 */
+ '\xff', '\xff', '\xff', '\xff', '\xff', /* 35 */
+ '\xff', '\xff', '\xff', '\x3e', '\xff', /* 40 */
+ '\xff', '\xff', '\x3f', '\x34', '\x35', /* 45 */
+ '\x36', '\x37', '\x38', '\x39', '\x3a', /* 50 */
+ '\x3b', '\x3c', '\x3d', '\xff', '\xff', /* 55 */
+ '\xff', '\xff', '\xff', '\xff', '\xff', /* 60 */
+ '\x00', '\x01', '\x02', '\x03', '\x04', /* 65 A */
+ '\x05', '\x06', '\x07', '\x08', '\x09', /* 70 */
+ '\x0a', '\x0b', '\x0c', '\x0d', '\x0e', /* 75 */
+ '\x0f', '\x10', '\x11', '\x12', '\x13', /* 80 */
+ '\x14', '\x15', '\x16', '\x17', '\x18', /* 85 */
+ '\x19', '\xff', '\xff', '\xff', '\xff', /* 90 */
+ '\xff', '\xff', '\x1a', '\x1b', '\x1c', /* 95 */
+ '\x1d', '\x1e', '\x1f', '\x20', '\x21', /* 100 */
+ '\x22', '\x23', '\x24', '\x25', '\x26', /* 105 */
+ '\x27', '\x28', '\x29', '\x2a', '\x2b', /* 110 */
+ '\x2c', '\x2d', '\x2e', '\x2f', '\x30', /* 115 */
+ '\x31', '\x32', '\x33', '\xff', '\xff', /* 120 */
+ '\xff', '\xff', '\xff', '\xff', '\xff',
+ '\xff', '\xff', '\xff', '\xff', '\xff', /* 125 */
+ '\xff', '\xff', '\xff', '\xff', '\xff',
+ '\xff', '\xff', '\xff', '\xff', '\xff',
+ '\xff', '\xff', '\xff', '\xff', '\xff',
+ '\xff', '\xff', '\xff', '\xff', '\xff',
+ '\xff', '\xff', '\xff', '\xff', '\xff',
+ '\xff', '\xff', '\xff', '\xff', '\xff', /* 155 */
+ '\xff', '\xff', '\xff', '\xff', '\xff',
+ '\xff', '\xff', '\xff', '\xff', '\xff',
+ '\xff', '\xff', '\xff', '\xff', '\xff',
+ '\xff', '\xff', '\xff', '\xff', '\xff',
+ '\xff', '\xff', '\xff', '\xff', '\xff',
+ '\xff', '\xff', '\xff', '\xff', '\xff', /* 185 */
+ '\xff', '\xff', '\xff', '\xff', '\xff',
+ '\xff', '\xff', '\xff', '\xff', '\xff',
+ '\xff', '\xff', '\xff', '\xff', '\xff',
+ '\xff', '\xff', '\xff', '\xff', '\xff',
+ '\xff', '\xff', '\xff', '\xff', '\xff',
+ '\xff', '\xff', '\xff', '\xff', '\xff', /* 215 */
+ '\xff', '\xff', '\xff', '\xff', '\xff',
+ '\xff', '\xff', '\xff', '\xff', '\xff',
+ '\xff', '\xff', '\xff', '\xff', '\xff',
+ '\xff', '\xff', '\xff', '\xff', '\xff',
+ '\xff', '\xff', '\xff', '\xff', '\xff',
+ '\xff', '\xff', '\xff', '\xff', '\xff', '\xff' /* 245 */
+ }
};
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.