Skip to content

Float overflows when cast to int in get_subbox_chart_physical() #3320

Open
@y-guyon

Description

System information (version)
  • OpenCV => 4.6
  • Operating System / Platform => Linux 64 Bit
  • Compiler => gcc
Detailed description

h may overflow the cast to int in get_subbox_chart_physical():

size = cv::Size((int)w, (int)h);

It may not SIGILL for you but you can add if (h > INT_MAX) abort(); to detect the issue.

Steps to reproduce

At head (cde1864 / 8eaa8ac) with input https://en.wikipedia.org/wiki/File:Gretag-Macbeth_ColorChecker.jpg:

#include "opencv2/imgcodecs.hpp"
#include "opencv2/mcc.hpp"

int main(int, char**) {
  cv::Mat mat = cv::imread("Gretag-Macbeth_ColorChecker.jpg");
  cv::Ptr<cv::mcc::CCheckerDetector> detector = cv::mcc::CCheckerDetector::create();
  cv::Ptr<cv::mcc::DetectorParameters> params = cv::mcc::DetectorParameters::create();
  params->adaptiveThreshWinSizeMin = 11;
  params->adaptiveThreshWinSizeStep = 4;
  detector->process(mat, cv::mcc::TYPECHART::MCC24, /*nc=*/1, /*use_net=*/false, params);
  return 0;
}
Issue submission checklist
  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues,
    forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files: videos, images, onnx, etc

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions