]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix hang in `named-compilezone | head`
authorTony Finch <dot@dotat.at>
Tue, 22 Oct 2019 14:37:38 +0000 (15:37 +0100)
committerMark Andrews <marka@isc.org>
Tue, 29 Oct 2019 23:53:14 +0000 (10:53 +1100)
I was truncating zone files for experimental purposes when I found
that `named-compilezone | head` got stuck. The full command line that
exhibited the problem was:

dig axfr dotat.at |
named-compilezone -o /dev/stdout dotat.at /dev/stdin |
head

This requires a large enough zone to exhibit the problem, more than
about 70000 bytes of plain text output from named-compilezone.
I was running the command on Debian Stretch amd64.

This was puzzling since it looked like something was suppressing the
SIGPIPE. I used `strace` to examine what was happening at the hang.
The program was just calling write() a lot to print the zone file, and
the last write() hanged until I sent it a SIGINT.

During some discussion with friends, Ian Jackson guessed that opening
/dev/stdout O_RDRW might be the problem, and after some tests we found
that this does in fact suppress SIGPIPE.

Since `named-compilezone` only needs to write to its output file, the
fix is to omit the stdio "+" update flag.

(cherry picked from commit a87ccea03209fed52824cc05fdc892d2358aeea0)

bin/check/check-tool.c

index dab9e8d394cb849bf2f95d142072f4d7e36e2f87..a95c42f94b1b7c7113d6c6b3d7d2903712b47150 100644 (file)
@@ -747,7 +747,7 @@ dump_zone(const char *zonename, dns_zone_t *zone, const char *filename,
        FILE *output = stdout;
        const char *flags;
 
-       flags = (fileformat == dns_masterformat_text) ? "w+" : "wb+";
+       flags = (fileformat == dns_masterformat_text) ? "w" : "wb";
 
        if (debug) {
                if (filename != NULL && strcmp(filename, "-") != 0)