Joe Conway <mail@joeconway.com> writes:
> The attached patch fixes this for me. I think it ought to be backpatched through
> pg11.
> Comments?
1. Doesn't seem to be accounting for the possibility of an error in fread().
2. Don't we want to remove the stat() call altogether, if we're not
going to believe its length?
3. This bit might need to cast the RHS to int64:
if (bytes_to_read > (MaxAllocSize - VARHDRSZ))
otherwise it might be treated as an unsigned comparison.
Or you could check for bytes_to_read < 0 separately.
4. appendStringInfoString seems like quite the wrong thing to use
when the input is binary data.
5. Don't like the comment. Whether the file is virtual or not isn't
very relevant here.
6. If the file size exceeds 1GB, I fear we'll get some rather opaque
failure from the stringinfo infrastructure. It'd be better to
check for that here and give a file-too-large error.
regards, tom lane