diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2018-01-19 12:52:27 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2018-01-24 14:13:19 +0100 |
commit | 2bc74c6683f4e45c4d7f60c652f906f2bc97db34 (patch) | |
tree | 53005d523f96f56005d0b7f03a66faa0131ee633 /source/fitz | |
parent | 321ee2df3061a0e30899ebc9ad70728bb557d7b6 (diff) | |
download | mupdf-2bc74c6683f4e45c4d7f60c652f906f2bc97db34.tar.xz |
Fix 698872: Do not trust ICC profile unconditionally in PNG files.
Diffstat (limited to 'source/fitz')
-rw-r--r-- | source/fitz/load-png.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/source/fitz/load-png.c b/source/fitz/load-png.c index 2fe58700..179297a3 100644 --- a/source/fitz/load-png.c +++ b/source/fitz/load-png.c @@ -7,6 +7,7 @@ struct info { unsigned int width, height, depth, n; + enum fz_colorspace_type type; int interlace, indexed; unsigned int size; unsigned char *samples; @@ -256,15 +257,16 @@ png_read_ihdr(fz_context *ctx, struct info *info, const unsigned char *p, unsign info->indexed = 0; if (color == 0) /* gray */ - info->n = 1; + info->n = 1, info->type = FZ_COLORSPACE_GRAY; else if (color == 2) /* rgb */ - info->n = 3; + info->n = 3, info->type = FZ_COLORSPACE_RGB; else if (color == 4) /* gray alpha */ - info->n = 2; + info->n = 2, info->type = FZ_COLORSPACE_GRAY; else if (color == 6) /* rgb alpha */ - info->n = 4; + info->n = 4, info->type = FZ_COLORSPACE_RGB; else if (color == 3) /* indexed */ { + info->type = FZ_COLORSPACE_RGB; /* after colorspace expansion it will be */ info->indexed = 1; info->n = 1; } @@ -529,6 +531,13 @@ png_read_image(fz_context *ctx, struct info *info, const unsigned char *p, size_ } } + if (info->cs && fz_colorspace_type(ctx, info->cs) != info->type) + { + fz_warn(ctx, "embedded ICC profile does not match PNG colorspace"); + fz_drop_colorspace(ctx, info->cs); + info->cs = NULL; + } + if (info->cs == NULL) { if (info->n == 3 || info->n == 4 || info->indexed) |