The isc_dnsstream_assembler_incoming() inline function expects that
when 'buf_size' is zero, then 'buf' must be NULL. The expectation is
not correct, because those values come from the libuv read callback,
and its documentation notes[1] that 'nread' ('buf_size' here) might
be 0, which does not indicate an error or EOF, but is equivalent to
EAGAIN or EWOULDBLOCK under read(2).
Change the isc_dnsstream_assembler_incoming() inline function to
remove the invalid expectation.
[1] https://docs.libuv.org/en/v1.x/stream.html#c.uv_read_cb
REQUIRE(dnsasm != NULL);
INSIST(!dnsasm->calling_cb);
- if (buf_size == 0) {
- INSIST(buf == NULL);
- } else {
+ if (buf != NULL && buf_size > 0) {
size_t remaining;
- INSIST(buf != NULL);
-
remaining = isc_buffer_remaininglength(&dnsasm->dnsbuf);
if (remaining == 0) {
* when receiving the next batch of data.
*/
return;
- } else if (remaining == 1 && buf_size > 0) {
+ } else if (remaining == 1) {
/* Mostly the same case as above, but we have incomplete
* message length in the buffer and received at least
* one byte to complete it.