mirror of
http://thekelleys.org.uk/git/dnsmasq.git
synced 2026-11-03 13:38:32 +00:00
Return an empty block from blockdata_alloc() for zero length.
738c049 turned the allocation loop in blockdata_alloc_real() from
do/while into for, so a zero length now returns NULL. find_soa() and
extract_addresses() start the chain for an RR with
blockdata_alloc(NULL, 0) and fill it with blockdata_expand(), so they
now fail on every SOA and every RR that is not an address, e.g., MX,
SRV, or SVCB, and those answers are no longer cached. A zero-length
RR also no longer survives cache_recv_insert().
Allocate one empty block for zero length, as before.
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
1 parent
2463798e03
commit
10fbc39cf5
1 file changed
+8
-4
+8
-4
@@ -91,6 +91,11 @@ static struct blockdata *blockdata_alloc_real(int fd, char *data, size_t len)
|
||||
struct blockdata **prev = &ret;
|
||||
size_t blen;
|
||||
int fail;
|
||||
|
||||
/* Zero length still gives one empty block, blockdata_alloc(NULL, 0)
|
||||
is how callers start a chain to add to with blockdata_expand(). */
|
||||
if (len == 0)
|
||||
return new_block();
|
||||
|
||||
for (fail = 0; len != 0; len -= blen)
|
||||
{
|
||||
@@ -252,10 +257,9 @@ void blockdata_write(struct blockdata *block, size_t len, int fd)
|
||||
}
|
||||
}
|
||||
|
||||
/* NOTE: this can fail (NULL return) for three possible reasons.
|
||||
1) len == 0 - trivial
|
||||
2) end of stream.
|
||||
3) malloc failure when allocating blocks.
|
||||
/* NOTE: this can fail (NULL return) for two possible reasons.
|
||||
1) end of stream.
|
||||
2) malloc failure when allocating blocks.
|
||||
|
||||
Unless EOF is encountered, len octets will always be read from the stream,
|
||||
even in memory allocation fails.
|
||||
|
||||
Reference in new issue
Block a user