Re: BUG #5416: int4inc() is wrong

From: John Regehr <regehr(at)cs(dot)utah(dot)edu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5416: int4inc() is wrong
Date: 2010-04-15 01:22:31
Message-ID: 4BC66A57.2030809@cs.utah.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi Tom,

> If you can show me rewrites of all the basic arithmetic operations that
> detect overflow in full compliance with the C standard, and are
> readable, portable, and efficient, I'm all ears.

These are the best ones that I know of:

https://www.securecoding.cert.org/confluence/display/seccode/INT32-C.+Ensure+that+operations+on+signed+integers+do+not+result+in+overflow

Even if you dislike these, please take a look at the safety checks for
shifts. The current postgresql shift functions need to be strengthened,
and it is easy to do.

John Regehr

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2010-04-15 01:59:39 Re: build error: strlcat/strlcpy used from heimdal libroken.so
Previous Message Bruce Momjian 2010-04-15 00:55:08 Re: initdb stores default client_encoding from environment-variable