Fix for bug 2772
It is possible to craft a TIFF document where the IFD list is circular, leading to an infinite loop while traversing the chain. The libtiff directory reader has a failsafe that will break out of this loop after reading 65535 directory entries, but it will continue processing, consuming time and resources to process what is essentially a bogus TIFF document.
This change fixes the above behavior by breaking out of processing when a TIFF document has >= 65535 directories and terminating with an error.