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
1 file changed