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 <[email protected]>
Reported-by: Zheng Hacker <[email protected]>
Reviewed-by: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/[email protected]

Branch
------
master

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

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

Reply via email to