patch-src_backend_libpq_ip_c 952 B

12345678910111213141516171819202122232425262728293031
  1. $OpenBSD: patch-src_backend_libpq_ip_c,v 1.2 2016/02/13 21:54:28 sthen Exp $
  2. Use the address family from the address, not from the netmask,
  3. since the latter is unreliable. Fixes "samenet"/"samehost".
  4. --- src/backend/libpq/ip.c.orig Mon Feb 8 21:15:19 2016
  5. +++ src/backend/libpq/ip.c Fri Feb 12 17:18:09 2016
  6. @@ -423,17 +423,16 @@ run_ifaddr_callback(PgIfAddrCallback callback, void *c
  7. /* Check that the mask is valid */
  8. if (mask)
  9. {
  10. - if (mask->sa_family != addr->sa_family)
  11. +
  12. + /* mask->sa_family can be different from addr->sa_family. */
  13. +
  14. + if (addr->sa_family == AF_INET)
  15. {
  16. - mask = NULL;
  17. - }
  18. - else if (mask->sa_family == AF_INET)
  19. - {
  20. if (((struct sockaddr_in *) mask)->sin_addr.s_addr == INADDR_ANY)
  21. mask = NULL;
  22. }
  23. #ifdef HAVE_IPV6
  24. - else if (mask->sa_family == AF_INET6)
  25. + else if (addr->sa_family == AF_INET6)
  26. {
  27. if (IN6_IS_ADDR_UNSPECIFIED(&((struct sockaddr_in6 *) mask)->sin6_addr))
  28. mask = NULL;