RE: [PATCH] Fix possible underflow in expression (maxoff - 1) - Mailing list pgsql-hackers

From Ranier Vilela
Subject RE: [PATCH] Fix possible underflow in expression (maxoff - 1)
Date
Msg-id MN2PR18MB2927453D38E58F35E047563DE34B0@MN2PR18MB2927.namprd18.prod.outlook.com
Whole thread Raw
In response to Re: [PATCH] Fix possible underflow in expression (maxoff - 1)  (Peter Geoghegan <pg@bowt.ie>)
Responses Re: [PATCH] Fix possible underflow in expression (maxoff - 1)  (Peter Geoghegan <pg@bowt.ie>)
List pgsql-hackers
>I think that you're being far too optimistic about your ability to
>detect and report valid issues using these static analysis tools. It's
>not possible to apply the information they provide without a high
l>evel understanding of the design of the code. There are already quite
>a few full time Postgres hackers that use tools like Coverity all the
>time.
I've been programming in C for a long time, and I'm getting better every day, I believe.
I'll arrive there.

>While it's certainly true that PageGetMaxOffsetNumber cannot in
>general be trusted to be > 0, we're talking about code that exists to
>deal with pages that are already full, and need to be split. It is
>impossible for "maxoff" to underflow, even if you deliberately corrupt
>a page image using a tool like pg_hexedit. Even if we failed to be
>sufficiently defensive about such a case (which is not the case), it
>wouldn't make any sense to fix it in this specific esoteric function,
>which is called when we've already decided to split the page (but only
>sometimes).
At this point you are right. I hope that in the future anyone who will use _bt_afternewitemoff will remember this
hiddendanger. 

> Sanitization needs to happen at some central choke point.
Surely that would be the best solution. But this is not a function of a static analysis tool.

>I strongly suggest confining all of this to a single thread, and
>stating your reasoning upfront.
I don't know what that means.

Best regards.
Ranier Vilela


pgsql-hackers by date:

Previous
From: Andreas Karlsson
Date:
Subject: Minor white space typo in documentation
Next
From: Peter Geoghegan
Date:
Subject: Re: [PATCH] Fix possible underflow in expression (maxoff - 1)