aboutsummaryrefslogtreecommitdiffstats
path: root/libgamma_behex_edid_uppercase.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-03-08 00:21:02 +0100
committerMattias Andrée <maandree@kth.se>2021-03-08 00:21:02 +0100
commitb058098fdcc5d4ed9b81fdb17f64820c0360ad48 (patch)
treee39e5f547b900922775d466507c29b352f046a53 /libgamma_behex_edid_uppercase.c
parentmisc (diff)
downloadlibgamma-b058098fdcc5d4ed9b81fdb17f64820c0360ad48.tar.gz
libgamma-b058098fdcc5d4ed9b81fdb17f64820c0360ad48.tar.bz2
libgamma-b058098fdcc5d4ed9b81fdb17f64820c0360ad48.tar.xz
m + style fix + check memory allocation overflows
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libgamma_behex_edid_uppercase.c')
-rw-r--r--libgamma_behex_edid_uppercase.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libgamma_behex_edid_uppercase.c b/libgamma_behex_edid_uppercase.c
index 5545aa5..4b25987 100644
--- a/libgamma_behex_edid_uppercase.c
+++ b/libgamma_behex_edid_uppercase.c
@@ -17,6 +17,10 @@ libgamma_behex_edid_uppercase(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;