From 615c08f2007f13a19e7448dba484668b7866d34b Mon Sep 17 00:00:00 2001 From: giraffedata Date: Sat, 19 Dec 2009 20:09:13 +0000 Subject: Check PNM plain format sample value against maxval when read by PAM routines git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1065 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- lib/libpamread.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/libpamread.c') diff --git a/lib/libpamread.c b/lib/libpamread.c index f4d85493..0506d020 100644 --- a/lib/libpamread.c +++ b/lib/libpamread.c @@ -71,9 +71,14 @@ readPlainNonPbmRow(const struct pam * const pamP, for (col = 0; col < pamP->width; ++col) { unsigned int plane; for (plane = 0; plane < pamP->depth; ++plane) - if (tuplerow) + if (tuplerow) { tuplerow[col][plane] = pm_getuint(pamP->file); - else + + if (tuplerow[col][plane] > pamP->maxval) + pm_error("Plane %u sample value %lu exceeds the " + "image maxval of %lu", + plane, tuplerow[col][plane], pamP->maxval); + } else pm_getuint(pamP->file); /* read data and discard */ } } -- cgit 1.4.1