Re: When is int32 not an int32?

From: "David E(dot) Wheeler" <david(at)justatheory(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: When is int32 not an int32?
Date: 2021-09-26 23:06:45
Message-ID: 04B7B087-8347-4931-9EC2-CFD8883852C6@justatheory.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sep 26, 2021, at 18:31, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> I'd bet more along the lines of "your overflow check is less portable than
> you thought”.

Oh well now that you mention it and I look past things, I see we’re using INT_MAX, but should probably use INT32_MAX.

https://github.com/theory/pg-semver/blob/87cc30cbe80aa3992a4af6f19a35a9441111a86c/src/semver.c#L145-L149

And also that the destination value we’re storing it in is an int parts[], not int32 parts[]. Which we do so we can parse numbers up to int size. But to Fetter’s point, we’re not properly handling something greater than int (usually int64, presumably). Not sure what changes are required to improve memory safety over and above using INT32_MAX instead of INT_MAX.

Thanks,

Daavid

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2021-09-26 23:25:25 Re: When is int32 not an int32?
Previous Message Chapman Flack 2021-09-26 23:03:30 Re: Add create and update timestamp to all objects