Fix big file support in cmake

Tested by Fabio
Fix infinite loop while feeding wrong data in stdin

Take into account that CachedFile::read might not always return
the number of elems we asked it to read

Bug #64967
Merge remote-tracking branch 'origin/poppler-0.22'