From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Daniel Gustafsson <daniel(at)yesql(dot)se> |
Cc: | Winter Loo <winterloo(at)126(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: may be a buffer overflow problem |
Date: | 2024-06-14 15:18:01 |
Message-ID: | 2298818.1718378281@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
I wrote:
> Seeing that this code is exercised thousands of times a day in the
> regression tests and has had a failure rate of exactly zero (and
> yes, the tests do check the output), there must be some reason
> why it's okay.
After looking a little closer, I think the reason why it works in
practice is that there's always a few bytes of zero padding at the
end of struct sqlca_t.
I don't see any value in changing individual code sites that are
depending on that, because there are surely many more, both in
our own code and end users' code. What I suggest we ought to do
is formalize the existence of that zero pad. Perhaps like this:
char sqlstate[5];
+ char sqlstatepad; /* nul terminator for sqlstate */
};
Another way could be to change
- char sqlstate[5];
+ char sqlstate[6];
but I fear that could have unforeseen consequences in code that
is paying attention to sizeof(sqlstate).
Either way there are probably doc adjustments to be made.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Justin Pryzby | 2024-06-14 15:22:01 | Re: CI and test improvements |
Previous Message | Andrew Dunstan | 2024-06-14 15:15:04 | Re: RFC: adding pytest as a supported test framework |