Skip to content

Null Pointer Dereference at ExpandRotateKernelInfo of MagickCore/morphology.c #774

@viennadd

Description

@viennadd

Hi all,

ImageMagick-7.0.6-5

CloneKernelInfo uses AcquireMagickMemory and it might return NULL, and causing Null Pointer Dereference and Denial of Service.

the following function ExpandRotateKernelInfo use CloneKernelInfo with out Null checking:

static void ExpandRotateKernelInfo(KernelInfo *kernel, const double angle)

static void ExpandRotateKernelInfo(KernelInfo *kernel, const double angle)
{
  KernelInfo
    *clone,
    *last;

  last = kernel;
DisableMSCWarning(4127)
  while(1) {
RestoreMSCWarning
    clone = CloneKernelInfo(last);      // returns NULL if it AcquireMagickMemory fails
    RotateKernelInfo(clone, angle);        // dereference variable clone
    if ( SameKernelInfo(kernel, clone) != MagickFalse )
      break;
    LastKernelInfo(last)->next = clone;
    last = clone;
  }
  clone = DestroyKernelInfo(clone); /* kernel has repeated - junk the clone */
  return;
}

Similar usage of CloneKernelInfo might share the same issue:

clone = CloneKernelInfo(last);

Regards,
Alex, SourceBrella Inc.

Metadata

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