git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d482f7f)
Properly determine length for on-disk TOAST values
2019年11月16日 01:40:02 +0000 (02:40 +0100)
2019年11月16日 02:07:11 +0000 (03:07 +0100)
In detoast_attr_slice, VARSIZE_ANY was used to compute compressed length
of on-disk TOAST values. That's incorrect, because the varlena value may
be just a TOAST pointer, producing either bogus value or crashing.

This is likely why the code was crashing on big-endian machines before
540f31680913 replaced the VARSIZE with VARSIZE_ANY, which however only
masked the issue.

Reported-by: Rushabh Lathia
Discussion: https://postgr.es/m/CAL-OGkthU9Gs7TZchf5OWaL-Gsi=hXqufTxKv9qpNG73d5na_g@mail.gmail.com


diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index f752ac7bbc917c1220eb764da6378a550d493b9d..8c89fc2a558bd6e199f92da55dec617fef9de403 100644 (file)
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -233,7 +233,7 @@ detoast_attr_slice(struct varlena *attr,
* of a given length (after decompression).
*/
max_size = pglz_maximum_compressed_size(sliceoffset + slicelength,
- TOAST_COMPRESS_SIZE(attr));
+ toast_pointer.va_extsize);
/*
* Fetch enough compressed slices (compressed marker will get set
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /