From 85fcf94eeae589641213c4301bbb16b44b10a282 Mon Sep 17 00:00:00 2001 From: kcwu Date: Mon, 17 Oct 2016 06:13:11 -0700 Subject: lcms: reject NaN when reading float numbers LerpFloat functions expect input values are normal float. They first clamp values to the range of [0.0, 1.0] and then calculate interpolation with the input values. If the input value is NaN, it will lead to heap buffer overflow because the index to LutTable is calculated based on the said value and fclamp(NaN) is not in expected [0.0, 1.0] range. This patch rejects all NaN values earlier when reading float numbers. So it also changed behavior for cases other than LerpFloat. I think it is okay because NaN doesn't make sense for usual calculations. BUG=654676 Review-Url: https://codereview.chromium.org/2422553002 --- third_party/lcms2-2.6/src/cmsplugin.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'third_party/lcms2-2.6/src') diff --git a/third_party/lcms2-2.6/src/cmsplugin.c b/third_party/lcms2-2.6/src/cmsplugin.c index 8903d2bd61..b95befbd96 100644 --- a/third_party/lcms2-2.6/src/cmsplugin.c +++ b/third_party/lcms2-2.6/src/cmsplugin.c @@ -179,6 +179,8 @@ cmsBool CMSEXPORT _cmsReadFloat32Number(cmsIOHANDLER* io, cmsFloat32Number* n) tmp = _cmsAdjustEndianess32(tmp); *n = *(cmsFloat32Number*) &tmp; + if (isnan(*n)) + return FALSE; } return TRUE; } -- cgit v1.2.3