Fix heap-buffer-overflow in function extractImageSection
This is a re-request of !476 (closed) which appears to have been abandoned.
Add boundary check before accessing memory to address CVE-2023-1916
This MR will fix the following tiffcrop issues: #536 (closed),#537 (closed)