pgsql: Improve error message for to lrage LO read requests

Started by Daniel Gustafsson3 days ago1 messagescommitters
Jump to latest
#1Daniel Gustafsson
dgustafsson@postgresql.org

Improve error message for to lrage LO read requests

Calling loread() with a length argument which exceeds the max
allocation yields an invalid memory alloc error message, and
if the length overflows it will be a nonsensical value which
can be confusing.

select loread(1, 2147483647);
ERROR: invalid memory alloc request size 18446744071562067971

Fix by detecting an oversize length request and error out like
how other LO read functions do. The error message is identical
to already existing messages to avoid new translation work.

This is not backpatched as the current behavior is safe, this
is only an improvement in the messaging.

Author: Daniel Gustafsson <daniel@yesql.se>
Reported-by: Zheng Hacker <hackerzheng666@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: /messages/by-id/19905-3f33374cbee82db1@postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2c077c7d602dba034e209227ea04a14b10797c42

Modified Files
--------------
src/backend/libpq/be-fsstubs.c | 5 +++++
1 file changed, 5 insertions(+)