0040-Fix-crash-when-negative-SRV-response-over-TCP-gets-s.patch 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. From e710c34469af4378c2db6fa0b0be88313adcb68f Mon Sep 17 00:00:00 2001
  2. From: Alin Nastac <alin.nastac@gmail.com>
  3. Date: Mon, 30 Sep 2019 15:30:26 +0100
  4. Subject: [PATCH] Fix crash when negative SRV response over TCP gets stored in
  5. LRU cache entry.
  6. Patch extended to receive side of pipe by SRK.
  7. ---
  8. src/cache.c | 8 ++++++--
  9. 1 file changed, 6 insertions(+), 2 deletions(-)
  10. --- a/src/cache.c
  11. +++ b/src/cache.c
  12. @@ -665,7 +665,11 @@ void cache_end_insert(void)
  13. if (flags & (F_IPV4 | F_IPV6 | F_DNSKEY | F_DS | F_SRV))
  14. read_write(daemon->pipe_to_parent, (unsigned char *)&new_chain->addr, sizeof(new_chain->addr), 0);
  15. if (flags & F_SRV)
  16. - blockdata_write(new_chain->addr.srv.target, new_chain->addr.srv.targetlen, daemon->pipe_to_parent);
  17. + {
  18. + /* A negative SRV entry is possible and has no data, obviously. */
  19. + if (!(flags & F_NEG))
  20. + blockdata_write(new_chain->addr.srv.target, new_chain->addr.srv.targetlen, daemon->pipe_to_parent);
  21. + }
  22. #ifdef HAVE_DNSSEC
  23. if (flags & F_DNSKEY)
  24. {
  25. @@ -737,7 +741,7 @@ int cache_recv_insert(time_t now, int fd
  26. if (!read_write(fd, (unsigned char *)&addr, sizeof(addr), 1))
  27. return 0;
  28. - if (flags & F_SRV && !(addr.srv.target = blockdata_read(fd, addr.srv.targetlen)))
  29. + if ((flags & F_SRV) && !(flags & F_NEG) && !(addr.srv.target = blockdata_read(fd, addr.srv.targetlen)))
  30. return 0;
  31. #ifdef HAVE_DNSSEC