From 9ba92bd728cadcc1811246e6d4242f03c49e82d9 Mon Sep 17 00:00:00 2001 From: Carlos Rafael Giani Date: Tue, 24 Mar 2026 17:05:09 +0100 Subject: [PATCH] spa: Do not perform upper range check on 32-bit platforms --- spa/include/spa/pod/body.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/spa/include/spa/pod/body.h b/spa/include/spa/pod/body.h index 4ab5d8e5f..90eadb82e 100644 --- a/spa/include/spa/pod/body.h +++ b/spa/include/spa/pod/body.h @@ -111,8 +111,15 @@ SPA_API_POD_BODY int spa_pod_choice_n_values(uint32_t choice_type, uint32_t *min SPA_API_POD_BODY int spa_pod_body_from_data(void *data, size_t maxsize, off_t offset, size_t size, struct spa_pod *pod, const void **body) { - if (offset < 0 || offset > (int64_t)UINT32_MAX) + if (offset < 0) return -EINVAL; + /* On 32-bit platforms, off_t is a signed 32-bit type (since it tracks pointer + * width), and consequently can never exceed UINT32_MAX. Skip the upper-bound + * check on 32-bit platforms to avoid a compiler warning. */ +#if __SIZEOF_POINTER__ > 4 + if (offset > (int64_t)UINT32_MAX) + return -EINVAL; +#endif if (size < sizeof(struct spa_pod) || size > maxsize || maxsize - size < (uint32_t)offset)