From 8f40796427b3591cd6dd1855813cfc7b2c0acb66 Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Wed, 8 Apr 2026 18:34:56 -0700 Subject: [PATCH] fixup! Consistently set specials[0] to 1 --- bin/dnssec/dnssec-ksr.c | 1 - bin/tools/named-rrchecker.c | 1 - fuzz/dns_rdata_fromtext.c | 2 +- fuzz/dns_rdata_fromwire_text.c | 1 - lib/dns/dst_api.c | 1 - lib/dns/master.c | 1 - lib/dns/skr.c | 1 - lib/isc/include/isc/lex.h | 2 +- lib/isc/lex.c | 9 +++++++-- lib/isccfg/parser.c | 1 - tests/dns/skr_test.c | 1 - tests/libtest/dns.c | 1 - 12 files changed, 9 insertions(+), 13 deletions(-) diff --git a/bin/dnssec/dnssec-ksr.c b/bin/dnssec/dnssec-ksr.c index 5088bb7d7e4..d2a38729090 100644 --- a/bin/dnssec/dnssec-ksr.c +++ b/bin/dnssec/dnssec-ksr.c @@ -1150,7 +1150,6 @@ sign(ksr_ctx_t *ksr) { inception = ksr->start; isc_lex_create(isc_g_mctx, KSR_LINESIZE, &lex); memset(specials, 0, sizeof(specials)); - specials[0] = 1; specials['('] = 1; specials[')'] = 1; specials['"'] = 1; diff --git a/bin/tools/named-rrchecker.c b/bin/tools/named-rrchecker.c index 28bbea39ab5..99a0ba4dfac 100644 --- a/bin/tools/named-rrchecker.c +++ b/bin/tools/named-rrchecker.c @@ -172,7 +172,6 @@ main(int argc, char *argv[]) { * Set up to lex DNS master file. */ - specials[0] = 1; specials['('] = 1; specials[')'] = 1; specials['"'] = 1; diff --git a/fuzz/dns_rdata_fromtext.c b/fuzz/dns_rdata_fromtext.c index 68c6894a306..a8ee8949b14 100644 --- a/fuzz/dns_rdata_fromtext.c +++ b/fuzz/dns_rdata_fromtext.c @@ -41,7 +41,7 @@ LLVMFuzzerInitialize(int *argc, char ***argv) { } /* following code was copied from named-rrchecker */ -isc_lexspecials_t specials = { [0] = 1, ['('] = 1, [')'] = 1, ['"'] = 1 }; +isc_lexspecials_t specials = { ['('] = 1, [')'] = 1, ['"'] = 1 }; int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { diff --git a/fuzz/dns_rdata_fromwire_text.c b/fuzz/dns_rdata_fromwire_text.c index 0e0f2447664..98ff4d46209 100644 --- a/fuzz/dns_rdata_fromwire_text.c +++ b/fuzz/dns_rdata_fromwire_text.c @@ -49,7 +49,6 @@ LLVMFuzzerInitialize(int *argc ISC_ATTR_UNUSED, char ***argv ISC_ATTR_UNUSED) { isc_lex_create(mctx, 64, &lex); memset(specials, 0, sizeof(specials)); - specials[0] = 1; specials['('] = 1; specials[')'] = 1; specials['"'] = 1; diff --git a/lib/dns/dst_api.c b/lib/dns/dst_api.c index 87480529b06..b8b673043b2 100644 --- a/lib/dns/dst_api.c +++ b/lib/dns/dst_api.c @@ -1490,7 +1490,6 @@ dst_key_read_public(const char *filename, int type, isc_mem_t *mctx, isc_lex_create(mctx, 1500, &lex); memset(specials, 0, sizeof(specials)); - specials[0] = 1; specials['('] = 1; specials[')'] = 1; specials['"'] = 1; diff --git a/lib/dns/master.c b/lib/dns/master.c index 4974999eeb6..0ae221c94e5 100644 --- a/lib/dns/master.c +++ b/lib/dns/master.c @@ -533,7 +533,6 @@ loadctx_create(dns_masterformat_t format, isc_mem_t *mctx, unsigned int options, * in lib/dns/tests/dnstest.c. */ memset(specials, 0, sizeof(specials)); - specials[0] = 1; specials['('] = 1; specials[')'] = 1; specials['"'] = 1; diff --git a/lib/dns/skr.c b/lib/dns/skr.c index 0b3b0435132..a54b843fc27 100644 --- a/lib/dns/skr.c +++ b/lib/dns/skr.c @@ -225,7 +225,6 @@ dns_skr_read(isc_mem_t *mctx, const char *filename, dns_name_t *origin, isc_lex_create(mctx, TOKENSIZ, &lex); memset(specials, 0, sizeof(specials)); - specials[0] = 1; specials['('] = 1; specials[')'] = 1; specials['"'] = 1; diff --git a/lib/isc/include/isc/lex.h b/lib/isc/include/isc/lex.h index a4faf25667a..684d8b416df 100644 --- a/lib/isc/include/isc/lex.h +++ b/lib/isc/include/isc/lex.h @@ -201,7 +201,7 @@ void isc_lex_setspecials(isc_lex_t *lex, isc_lexspecials_t specials); /*!< * The characters in 'specials' are returned as tokens. Along with - * whitespace, they delimit strings and numbers. + * whitespace and NUL, they delimit strings and numbers. * * Note: *\li Comment processing takes precedence over special character diff --git a/lib/isc/lex.c b/lib/isc/lex.c index 588ffa6bf1e..1019c112c8c 100644 --- a/lib/isc/lex.c +++ b/lib/isc/lex.c @@ -540,6 +540,10 @@ isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp) { lex->last_was_eol = false; no_comments = true; state = lexstate_qstring; + } else if (c == '\0') { + tokenp->type = isc_tokentype_unknown; + tokenp->value.as_char = c; + done = true; } else if (lex->specials[c]) { lex->last_was_eol = false; if ((c == '(' || c == ')') && @@ -607,7 +611,8 @@ isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp) { case lexstate_number: if (c == EOF || !isdigit((unsigned char)c)) { if (c == ' ' || c == '\t' || c == '\r' || - c == '\n' || c == EOF || lex->specials[c]) + c == '\n' || c == '\0' || c == EOF || + lex->specials[c]) { int base; if ((options & ISC_LEXOPT_OCTAL) != 0) { @@ -699,7 +704,7 @@ isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp) { * EOF needs to be checked before lex->specials[c] * as lex->specials[EOF] is not a good idea. */ - if (c == '\r' || c == '\n' || c == EOF || + if (c == '\r' || c == '\n' || c == EOF || c == '\0' || (!escaped && (c == ' ' || c == '\t' || lex->specials[c]))) { diff --git a/lib/isccfg/parser.c b/lib/isccfg/parser.c index 188919f14f7..83722cb858f 100644 --- a/lib/isccfg/parser.c +++ b/lib/isccfg/parser.c @@ -698,7 +698,6 @@ parser_create(cfg_parser_t **ret) { pctx->buf_name = NULL; memset(specials, 0, sizeof(specials)); - specials[0] = 1; specials['{'] = 1; specials['}'] = 1; specials[';'] = 1; diff --git a/tests/dns/skr_test.c b/tests/dns/skr_test.c index 55b533dc520..602f0df0675 100644 --- a/tests/dns/skr_test.c +++ b/tests/dns/skr_test.c @@ -168,7 +168,6 @@ write_record(FILE *fp, dns_rdatatype_t rdtype, const char *rdatastr, /* Create a lexer as one is required by dns_rdata_fromtext(). */ isc_lex_create(isc_g_mctx, 64, &lex); - specials[0] = 1; specials['('] = 1; specials[')'] = 1; specials['"'] = 1; diff --git a/tests/libtest/dns.c b/tests/libtest/dns.c index 9b6b8dc655d..e98b0e15b18 100644 --- a/tests/libtest/dns.c +++ b/tests/libtest/dns.c @@ -350,7 +350,6 @@ dns_test_rdatafromstring(dns_rdata_t *rdata, dns_rdataclass_t rdclass, * delimiters while reading the source string. These should match * specials from lib/dns/master.c. */ - specials[0] = 1; specials['('] = 1; specials[')'] = 1; specials['"'] = 1; -- 2.47.3