Fix incorrect size check in statext_dependencies_deserialize

Started by Ilia Evdokimov5 days ago2 messageshackers
Jump to latest
#1Ilia Evdokimov
ilya.evdokimov@tantorlabs.com

Hi hackers,

I noticed an issue in `statext_dependencies_deserialize()`. The sanity
check uses `SizeOfItem` to validate the bytea size, but `SizeOfItem()`
expects the number of attributes in a single dependency, not the number
of dependencies. This means the check is computing the size of one
dependency with ndeps attributes, which is incorrect.

It should use `MinSizeOfItems` instead, which correctly computes the
minimum expected size as the header plus `ndeps` minimally-sized
dependency items.

Notably, the similar function for ndistinct extended statistics
`statext_ndistinct_deserialize()` already uses `MinSizeOfItems`
correctly, which suggests this is a typo rather than an intentional choice.

--
Best regards,
Ilia Evdokimov,
Tantor Labs LLC,
https://tantorlabs.com/

Attachments:

v1-0001-Fix-size-check-in-statext_dependencies_deserializ.patchtext/x-patch; charset=UTF-8; name=v1-0001-Fix-size-check-in-statext_dependencies_deserializ.patchDownload+1-2
#2Michael Paquier
michael@paquier.xyz
In reply to: Ilia Evdokimov (#1)
Re: Fix incorrect size check in statext_dependencies_deserialize

On Tue, May 19, 2026 at 05:29:56PM +0300, Ilia Evdokimov wrote:

It should use `MinSizeOfItems` instead, which correctly computes the minimum
expected size as the header plus `ndeps` minimally-sized dependency items.

Notably, the similar function for ndistinct extended statistics
`statext_ndistinct_deserialize()` already uses `MinSizeOfItems` correctly,
which suggests this is a typo rather than an intentional choice.

Good catch, nice! This looks like a typo from d08c44f7a4ec to me,
where MinSizeOfItems sticks to the definition we have for MVDependency
in statistics.h.

Will fix.
--
Michael