On 2015-02-16 23:21, Jérémie Courrèges-Anglas wrote: > j...@wxcvbn.org (Jérémie Courrèges-Anglas) writes: > > > Please try the diff below. It fixes the "backwards memcpy" problem > > easily noticeable with psql -h ::1. > > Updated diff. Thanks to Stuart for reminding me that netmasks sa_len > values can be much surprising. > > $OpenBSD$ > --- src/backend/libpq/hba.c.orig Mon Feb 16 21:53:21 2015 > +++ src/backend/libpq/hba.c Mon Feb 16 23:08:38 2015 > @@ -700,8 +700,13 @@ check_ip(SockAddr *raddr, struct sockaddr * addr, stru > struct sockaddr_storage addrcopy, > maskcopy; > > - memcpy(&addrcopy, &addr, sizeof(addrcopy)); > - memcpy(&maskcopy, &mask, sizeof(maskcopy)); > + memcpy(&addrcopy, addr, sizeof(struct sockaddr_in)); > + /* > + * On some OSes, if mask is obtained from eg. getifaddrs(3), > sa_len > + * can vary wildly. We already know that addr->sa_family == > AF_INET, > + * so just use sizeof(struct sockaddr_in). > + */ > + memcpy(&maskcopy, mask, sizeof(struct sockaddr_in)); > pg_promote_v4_to_v6_addr(&addrcopy); > pg_promote_v4_to_v6_mask(&maskcopy); >
I can confirm that this works. The server has been up and running with no issues during a few hours. Will anybody be submiting this upstream? Thanks for all your help! -- Hugo Osvaldo Barrera A: Because we read from top to bottom, left to right. Q: Why should I start my reply below the quoted text? [demime 1.01d removed an attachment of type application/pgp-signature which had a name of signature.asc]