Fwd: Re: postgresql-server exiting abnormally after upgrade to -snapshot

From: Hugo Osvaldo Barrera <hugo(at)barrera(dot)io>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Fwd: Re: postgresql-server exiting abnormally after upgrade to -snapshot
Date: 2015-02-17 14:38:46
Message-ID: 20150217143846.GA25948@athena.barrera.io
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

This comes as a follow-up on a recent issue I mentioned and was discussed on
this list. (See thread [1]).

The included patch fixes the issue and postgres has been working fine for me
with it. See this thread[2] for details.

Cheers,

----- Forwarded message from Jérémie Courrèges-Anglas <jca(at)wxcvbn(dot)org> -----

> Date: Mon, 16 Feb 2015 23:21:05 +0100
> From: Jérémie Courrèges-Anglas <jca(at)wxcvbn(dot)org>
> Subject: Re: postgresql-server exiting abnormally after upgrade to -snapshot
> To: Hugo Osvaldo Barrera <hugo(at)barrera(dot)io>
> Cc: misc(at)openbsd(dot)org
> Mail-Followup-To: Hugo Osvaldo Barrera <hugo(at)barrera(dot)io>, misc(at)openbsd(dot)org
>
> jca(at)wxcvbn(dot)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);
>
>
>
> --
> jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
>

----- End forwarded message -----

[1]: http://www.postgresql.org/message-id/20150216202138.GB20474@athena.barrera.io
[2]: https://marc.info/?t=142367714200001&r=1&w=2

--
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?

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2015-02-17 15:06:06 Re: Fwd: Re: postgresql-server exiting abnormally after upgrade to -snapshot
Previous Message Tom Lane 2015-02-17 00:38:17 Re: postgresql-server exiting abnormally after an OS upgrade