Skip to content
GitLab
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
    Projects Groups Topics Snippets
  • Register
  • Sign in
  • L libtiff
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 137
    • Issues 137
    • List
    • Boards
    • Service Desk
    • Milestones
    • Requirements
  • Merge requests 23
    • Merge requests 23
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • libtiff
  • libtiff
  • Merge requests
  • !346

fix the FPE in tiffcrop (#415, #427, and #428)

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged 4ugustus requested to merge waugustus/libtiff:issue-415+427+428 into master Jun 02, 2022
  • Overview 3
  • Commits 2
  • Pipelines 4
  • Changes 3

Fix #415 (closed), #427 (closed), and #428 (closed).

I have made two editions:

First, I created a convert function (_TIFFClampDoubleToUInt32) in tif_aux.c, and declared it in tiffiop.h. Then I called this function on all lines of code that convert double to uint32_t. I did this because converting double to uint32_t with (uint32_t) will cause some large double values to be truncated.

//tif_aux.c
uint32_t _TIFFClampDoubleToUInt32(double val)
{
    if( val < 0 )
        return 0;
    if( val > 0xFFFFFFFFU || val != val )
        return 0xFFFFFFFFU;
    return (uint32_t)val;
}

//tiffiop.h
extern float _TIFFClampDoubleToFloat(double);
extern uint32_t _TIFFClampDoubleToUInt32(double);

Second, I added a check for integer overflow in tiffcrop.c.

if (owidth == 0 || olength == 0)
{
    TIFFError("computeOutputPixelOffsets", "Integer overflow when calculating the number of pages");
    exit(EXIT_FAILURE);
}
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: issue-415+427+428