From a7d6b7c30a7c8de7c1bd306d3766033e1f49397e Mon Sep 17 00:00:00 2001 From: Vasily Khoruzhick Date: Fri, 30 Nov 2012 15:17:32 +0300 Subject: [PATCH] nbis: Fix crash in gen_initial_maps() If the image is too small some coordinates can become negative. Handle this to avoid memory corruption. https://bugs.freedesktop.org/show_bug.cgi?id=57730 --- libfprint/nbis/mindtct/maps.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libfprint/nbis/mindtct/maps.c b/libfprint/nbis/mindtct/maps.c index 6f49e3c..43929a4 100644 --- a/libfprint/nbis/mindtct/maps.c +++ b/libfprint/nbis/mindtct/maps.c @@ -307,6 +307,10 @@ int gen_initial_maps(int **odmap, int **olcmap, int **olfmap, xmaxlimit = pw - dftgrids->pad - lfsparms->windowsize - 1; ymaxlimit = ph - dftgrids->pad - lfsparms->windowsize - 1; + /* max limits should not be negative */ + xmaxlimit = MAX(xmaxlimit, 0); + ymaxlimit = MAX(ymaxlimit, 0); + /* Foreach block in image ... */ for(bi = 0; bi < bsize; bi++){ /* Adjust block offset from pointing to block origin to pointing */