From 3c9bd37fa1fb42cf00949a5975d17d4a99cc3649 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 16 May 2024 11:03:20 +0200 Subject: [PATCH] acp: handle some errors better Handle allocation failure and size overflow. --- spa/plugins/alsa/acp/compat.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spa/plugins/alsa/acp/compat.h b/spa/plugins/alsa/acp/compat.h index 3e704ddf6..51f53c680 100644 --- a/spa/plugins/alsa/acp/compat.h +++ b/spa/plugins/alsa/acp/compat.h @@ -35,6 +35,7 @@ extern "C" { #include #include #include +#include #include @@ -660,6 +661,8 @@ static inline char *pa_readlink(const char *p) { ssize_t n; c = pa_xmalloc(l); + if (c == NULL) + return NULL; if ((n = readlink(p, c, l-1)) < 0) { pa_xfree(c); @@ -672,6 +675,9 @@ static inline char *pa_readlink(const char *p) { } pa_xfree(c); + + if (l >= (size_t)(INT_MAX / 2)) + return NULL; l *= 2; } #else