Skip to content

Reset bind.keys parser after error on file

In rare cases when parser of /etc/bind.keys reaches wrong syntax, it may terminate before reaching end of file. Then it may fail assertion failure in cfg_parse_buffer() on anchortext. It expects no source files exists, but there might be some left from previous parsing.

Reset parser on error from file parsing.

Minimal reproducer:

$ cat > /etc/bind.keys << EOF
trusted-keys { . static; };
EOF
$ delv

RH Bug: https://bugzilla.redhat.com/show_bug.cgi?id=2096248

If not fixed, it crashes delv with following traceback:

Thread 1 "delv" received signal SIGABRT, Aborted.
__pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
44	      return INTERNAL_SYSCALL_ERROR_P (ret) ? INTERNAL_SYSCALL_ERRNO (ret) : 0;
(gdb) bt
#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x00007ffff7ab1d23 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2  0x00007ffff7a61b66 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x00007ffff7a4b7f4 in __GI_abort () at abort.c:79
#4  0x00007ffff7f062e5 in isc_assertion_failed (file=file@entry=0x7ffff7f9c014 "../../../lib/isccfg/parser.c", line=line@entry=3595, type=type@entry=isc_assertiontype_insist, 
    cond=cond@entry=0x7ffff7f9c313 "elt != ((void *)0)") at ../../../lib/isc/assertions.c:49
#5  0x00007ffff7f91a1d in cfg_gettoken (pctx=pctx@entry=0x55555689ec20, options=options@entry=0) at ../../../lib/isccfg/parser.c:3595
#6  0x00007ffff7f99302 in cfg_parse_mapbody (pctx=0x55555689ec20, type=<optimized out>, ret=0x7fffffffd510) at ../../../lib/isccfg/parser.c:2379
#7  0x00007ffff7f8e2b0 in cfg_parse_obj (pctx=pctx@entry=0x55555689ec20, type=type@entry=0x7ffff7fab1c0 <cfg_type_bindkeys>, ret=ret@entry=0x7fffffffd510)
    at ../../../lib/isccfg/parser.c:243
#8  0x00007ffff7f980c3 in parse2 (pctx=pctx@entry=0x55555689ec20, type=type@entry=0x7ffff7fab1c0 <cfg_type_bindkeys>, ret=ret@entry=0x7fffffffd620)
    at ../../../lib/isccfg/parser.c:625
#9  0x00007ffff7f98442 in cfg_parse_buffer (pctx=0x55555689ec20, buffer=buffer@entry=0x7fffffffd650, file=file@entry=0x0, line=line@entry=0, 
    type=0x7ffff7fab1c0 <cfg_type_bindkeys>, flags=flags@entry=0, ret=0x7fffffffd620) at ../../../lib/isccfg/parser.c:698
#10 0x0000555555559469 in setup_dnsseckeys (client=0x5555555fd7c0) at ../../../bin/delv/delv.c:855
#11 main (argc=<optimized out>, argv=<optimized out>) at ../../../bin/delv/delv.c:1791
Edited by Petr Menšík

Merge request reports