From b058098fdcc5d4ed9b81fdb17f64820c0360ad48 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 8 Mar 2021 00:21:02 +0100 Subject: m + style fix + check memory allocation overflows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libgamma_behex_edid_lowercase.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'libgamma_behex_edid_lowercase.c') diff --git a/libgamma_behex_edid_lowercase.c b/libgamma_behex_edid_lowercase.c index 9c4f04e..41a2563 100644 --- a/libgamma_behex_edid_lowercase.c +++ b/libgamma_behex_edid_lowercase.c @@ -17,6 +17,10 @@ libgamma_behex_edid_lowercase(const unsigned char *restrict edid, size_t length) size_t i; /* Allocate memory area for the output string */ + if (length > (SIZE_MAX / sizeof(char) - 1) / 2) { + errno = ENOMEM; + return NULL; + } out = malloc((length * 2 + 1) * sizeof(char)); if (!out) return NULL; -- cgit v1.2.3-70-g09d2