Skip to content

Division by zero in ApplyFunction() of MagickCore/statistic.c #3332

@wuruoyu

Description

@wuruoyu

Prerequisites

  • [√] I have written a descriptive issue title
  • [√] I have verified that I am using the latest version of ImageMagick
  • [√] I have searched open and closed issues to ensure it has not already been reported

Description

A division-by-zero exception can happen in function ApplyFunction() when the arguments function = ArcsinFunction and parameters[0] = 0. Please refer to the code below:

width=(number_parameters >= 1) ? parameters[0] : 1.0;
center=(number_parameters >= 2) ? parameters[1] : 0.5;
range=(number_parameters >= 3) ? parameters[2] : 1.0;
bias=(number_parameters >= 4) ? parameters[3] : 0.5;
result=2.0/width*(QuantumScale*pixel-center);

ApplyFunction() is called in FunctionImage(), which is an API function. Before calling ApplyFunction(), no sanity check is imposed. So an attacker can call FunctionImage() with function = ArcsinFunction and parameters[0] = 0 to trigger this exception.

q[i]=ApplyFunction(q[i],function,number_parameters,parameters,

Thank you in advance! Let me know if you have any questions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions