2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-06-05 20:00:53 +00:00

PNGFilter: Better range checking for columns

This commit is contained in:
Jay Berkenbilt 2017-08-31 07:26:58 -04:00
parent ec7d74a386
commit 3ef1be9783

View File

@ -1,6 +1,7 @@
#include <qpdf/Pl_PNGFilter.hh>
#include <stdexcept>
#include <string.h>
#include <limits.h>
Pl_PNGFilter::Pl_PNGFilter(char const* identifier, Pipeline* next,
action_e action, unsigned int columns,
@ -14,9 +15,10 @@ Pl_PNGFilter::Pl_PNGFilter(char const* identifier, Pipeline* next,
buf2(0),
pos(0)
{
if (columns == 0)
if ((columns == 0) || (columns > UINT_MAX - 1))
{
throw std::runtime_error("PNGFilter created with columns = 0");
throw std::runtime_error(
"PNGFilter created with invalid columns value");
}
this->buf1 = new unsigned char[columns + 1];
this->buf2 = new unsigned char[columns + 1];