Code: static double outerr(PNG_CONST png_modifier *pm, int in_depth, int out_depth)
 {
    /* There is a serious error in the 2 and 4 bit grayscale transform because
     * the gamma table value (8 bits) is simply shifted, not rounded, so the
    * error in 4 bit grayscale gamma is up to the value below.  This is a hack
    * to allow pngvalid to succeed:
    *
    * TODO: fix this in libpng
    */
 if (out_depth == 2)
 return .73182-.5;

 if (out_depth == 4)
 return .90644-.5;

 if ((pm->calculations_use_input_precision ? in_depth : out_depth) == 16)
 return pm->maxout16;

 /* This is the case where the value was calculated at 8-bit precision then
    * scaled to 16 bits.
    */
 else if (out_depth == 16)
 return pm->maxout8 * 257;

 else
 return pm->maxout8;
}

Vulnerability Type: +Priv 
CWE ID: 
Summary: Unspecified vulnerability in libpng before 1.6.20, as used in Android 4.x before 4.4.4, 5.0.x before 5.0.2, 5.1.x before 5.1.1, and 6.x before 2016-07-01, allows attackers to gain privileges via a crafted application, as demonstrated by obtaining Signature or SignatureOrSystem access, aka internal bug 23265085.
Commit Message: DO NOT MERGE Update libpng to 1.6.20

BUG:23265085
Change-Id: I85199805636d771f3597b691b63bc0bf46084833
(cherry picked from commit bbe98b40cda082024b669fa508931042eed18f82)
