Re: When is int32 not an int32? - Mailing list pgsql-hackers

From David E. Wheeler
Subject Re: When is int32 not an int32?
Date
Msg-id 04B7B087-8347-4931-9EC2-CFD8883852C6@justatheory.com
Whole thread Raw
In response to Re: When is int32 not an int32?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: When is int32 not an int32?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Sep 26, 2021, at 18:31, Tom Lane <tgl@sss.pgh.pa.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
parsenumbers 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
ofINT_MAX. 

Thanks,

Daavid


Attachment

pgsql-hackers by date:

Previous
From: Chapman Flack
Date:
Subject: Re: Add create and update timestamp to all objects
Next
From: Tom Lane
Date:
Subject: Re: When is int32 not an int32?