bind9/bin/confgen
Ondřej Surý 46f6bb6364
Size HMAC key generation buffers to the maximum block size
hmac_generate() declared its on-stack nonce buffer as
unsigned char data[ISC_MAX_MD_SIZE], i.e. 64 bytes. That is the maximum
digest size, but the buffer is filled up to the algorithm's HMAC block
size, which is 128 bytes for SHA-384 and SHA-512. Asking rndc-confgen
for an HMAC-SHA-384 or HMAC-SHA-512 key with -b > 512 (the documented
range allows up to 1024) wrote past the end of the stack buffer; on
hardened builds this aborted with a stack-smash detector firing
instead of producing a key.

Use the existing ISC_MAX_BLOCK_SIZE (128) for the buffer so the full
1..1024 range advertised by -A hmac-sha{384,512} works as documented.
The matching key_rawsecret[64] in confgen's generate_key() is enlarged
the same way so the generated key fits when dumped to the buffer.

Add a system test that exercises rndc-confgen across the previously
overflowing keysizes; with -Db_sanitize=address it caught the abort
before the fix.

Assisted-by: Claude:claude-opus-4-7
2026-04-29 19:21:20 +02:00
..
include Remove C++ support from the public header 2024-12-18 13:10:39 +01:00
.gitignore [master] update gitignore files; use rev-parse to get srcid 2014-06-17 13:49:30 -07:00
ddns-confgen.rst Add internal hyperlinks to See Also section of manual pages 2022-03-14 10:46:36 +01:00
keygen.c Size HMAC key generation buffers to the maximum block size 2026-04-29 19:21:20 +02:00
keygen.h Reject unsafe key names in rndc-confgen, tsig-keygen, ddns-confgen 2026-04-29 18:12:35 +02:00
meson.build replace the build system with meson 2025-06-11 10:30:12 +03:00
os.c Remove redundant parentheses from the return statement 2024-11-19 12:27:22 +01:00
rndc-confgen.c Reject unsafe key names in rndc-confgen, tsig-keygen, ddns-confgen 2026-04-29 18:12:35 +02:00
rndc-confgen.rst Add internal hyperlinks to See Also section of manual pages 2022-03-14 10:46:36 +01:00
tsig-keygen.c Reject unsafe key names in rndc-confgen, tsig-keygen, ddns-confgen 2026-04-29 18:12:35 +02:00
tsig-keygen.rst Put reference to RFC 2845 in tsig-keygen man page 2024-02-01 11:20:33 +01:00
util.c Unify handling of the program name in all the utilities 2025-05-29 06:17:32 +02:00
util.h Remove C++ support from the public header 2024-12-18 13:10:39 +01:00