Fix T82602: checking image header reads past buffer bounds

Use the size argument to ensure checking the header doesn't read
past the buffer bounds when reading corrupt/truncated headers
from image files.
This commit is contained in:
2020-11-11 16:14:09 +11:00
parent 2d60845786
commit 15ffda3bcd
14 changed files with 95 additions and 49 deletions

View File

@@ -243,8 +243,11 @@ static void test_endian_zbuf(struct ImBuf *ibuf)
/* this one is only def-ed once, strangely... */
#define GSS(x) (((uchar *)(x))[1] << 8 | ((uchar *)(x))[0])
bool imb_is_a_iris(const uchar *mem, size_t UNUSED(size))
bool imb_is_a_iris(const uchar *mem, size_t size)
{
if (size < 2) {
return false;
}
return ((GS(mem) == IMAGIC) || (GSS(mem) == IMAGIC));
}