From 239034714f28e775fa7c4d1c26e2f876e6fed4a2 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Thu, 13 Dec 2018 15:19:26 +0100 Subject: [PATCH] mindtct: Check for multiplication overflow in gen_quality_map() Assert if any of the multiplications, which are then used to allocate memory, would overflow. Closes: #103 --- libfprint/nbis/mindtct/quality.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libfprint/nbis/mindtct/quality.c b/libfprint/nbis/mindtct/quality.c index db2bc5c..94e9b63 100644 --- a/libfprint/nbis/mindtct/quality.c +++ b/libfprint/nbis/mindtct/quality.c @@ -115,6 +115,9 @@ int gen_quality_map(int **oqmap, int *direction_map, int *low_contrast_map, int arrayPos, arrayPos2; int QualOffset; + ASSERT_SIZE_MUL(map_w, map_h); + ASSERT_SIZE_MUL(map_w * map_h, sizeof(int)); + QualMap = (int *)malloc(map_w * map_h * sizeof(int)); if(QualMap == (int *)NULL){ fprintf(stderr, "ERROR : gen_quality_map : malloc : QualMap\n");