Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12:Update
openexr.21777
openexr-CVE-2021-3941.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File openexr-CVE-2021-3941.patch of Package openexr.21777
Index: openexr-2.1.0/IlmImf/ImfChromaticities.cpp =================================================================== --- openexr-2.1.0.orig/IlmImf/ImfChromaticities.cpp 2013-06-18 21:51:39.000000000 +0200 +++ openexr-2.1.0/IlmImf/ImfChromaticities.cpp 2021-11-11 10:45:42.601610005 +0100 @@ -44,6 +44,10 @@ #include "ImfNamespace.h" #include <string.h> +#include <stdlib.h> +#include <stdexcept> +#include <float.h> + OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER @@ -90,34 +94,59 @@ RGBtoXYZ (const Chromaticities chroma, f // X and Z values of RGB value (1, 1, 1), or "white" // + // prevent a division that rounds to zero + if (fabs(chroma.white.y) <= 1.f && fabs(chroma.white.x * Y) >= fabs(chroma.white.y) * FLT_MAX) + { + throw std::invalid_argument("Bad chromaticities: white.y cannot be zero"); + } + float X = chroma.white.x * Y / chroma.white.y; float Z = (1 - chroma.white.x - chroma.white.y) * Y / chroma.white.y; // - // Scale factors for matrix rows + // Scale factors for matrix rows, compute numerators and common denominator // float d = chroma.red.x * (chroma.blue.y - chroma.green.y) + chroma.blue.x * (chroma.green.y - chroma.red.y) + chroma.green.x * (chroma.red.y - chroma.blue.y); - float Sr = (X * (chroma.blue.y - chroma.green.y) - + + + float SrN = (X * (chroma.blue.y - chroma.green.y) - chroma.green.x * (Y * (chroma.blue.y - 1) + chroma.blue.y * (X + Z)) + chroma.blue.x * (Y * (chroma.green.y - 1) + - chroma.green.y * (X + Z))) / d; + chroma.green.y * (X + Z))); + - float Sg = (X * (chroma.red.y - chroma.blue.y) + + float SgN = (X * (chroma.red.y - chroma.blue.y) + chroma.red.x * (Y * (chroma.blue.y - 1) + chroma.blue.y * (X + Z)) - chroma.blue.x * (Y * (chroma.red.y - 1) + - chroma.red.y * (X + Z))) / d; + chroma.red.y * (X + Z))); - float Sb = (X * (chroma.green.y - chroma.red.y) - + float SbN = (X * (chroma.green.y - chroma.red.y) - chroma.red.x * (Y * (chroma.green.y - 1) + chroma.green.y * (X + Z)) + chroma.green.x * (Y * (chroma.red.y - 1) + - chroma.red.y * (X + Z))) / d; + chroma.red.y * (X + Z))); + + + if ( fabs(d)<1.f && (fabs(SrN) >= fabs(d)* FLT_MAX || fabs(SgN) >= fabs(d)* FLT_MAX || fabs(SbN) >= fabs(d)* FLT_MAX) ) + { + // cannot generate matrix if all RGB primaries have the same y value + // or if they all have the an x value of zero + // in both cases, the primaries are colinear, which makes them unusable + throw std::invalid_argument("Bad chromaticities: RGBtoXYZ matrix is degenerate"); + } + + + + float Sr = SrN / d; + float Sg = SgN / d; + float Sb = SbN / d; + // // Assemble the matrix
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor