### ImageMagick version

7.1.1-30

### Operating system

Linux

### Operating system, version and so on

Ubuntu 20.04 LTS

### Description

```
./rotate_fuzzer  ./out_rotate_crash/default/crashes/id\:000000\,sig\:06\,src\:016175+01
3217_time\:36400038_execs\:207091_op\:splice_rep\:16 
Reading 537 bytes from ./out_rotate_crash/default/crashes/id:000000,sig:06,src:016175+013217_time:36400038_execs:207091_op:splice_rep:16
=================================================================
==41886==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x606000002f3c at pc 0x000001b223d4 bp 0x7ffe5bca4120 sp 0x7ffe5bca4118
WRITE of size 4 at 0x606000002f3c thread T0
    #0 0x1b223d3 in opj_jp2_read_header /home/fuzz/Desktop/DDGF_Project/OSS-Test/mylibs/openjpeg/src/lib/openjp2/jp2.c:2875:37
    #1 0x135795e in ReadJP2Image /home/fuzz/Desktop/DDGF_Project/OSS-Test/ImageMagick/coders/jp2.c:359:7
    #2 0x9c90d4 in ReadImage /home/fuzz/Desktop/DDGF_Project/OSS-Test/ImageMagick/MagickCore/constitute.c:736:15
    #3 0x9439d5 in BlobToImage /home/fuzz/Desktop/DDGF_Project/OSS-Test/ImageMagick/MagickCore/blob.c:479:13
    #4 0x8190b1 in Magick::Image::read(Magick::Blob const&) /home/fuzz/Desktop/DDGF_Project/OSS-Test/ImageMagick/Magick++/lib/Image.cpp:4044:12
    #5 0x37a3006 in LLVMFuzzerTestOneInput /home/fuzz/Desktop/DDGF_Project/OSS-Test/ImageMagick/oss-fuzz/rotate_fuzzer.cc:42:11
    #6 0x8015dd in ExecuteFilesOnyByOne /home/fuzz/Desktop/DDGF_Project/AFLplusplus/utils/aflpp_driver/aflpp_driver.c:255:7
    #7 0x8013e8 in LLVMFuzzerRunDriver /home/fuzz/Desktop/DDGF_Project/AFLplusplus/utils/aflpp_driver/aflpp_driver.c
    #8 0x800fa8 in main /home/fuzz/Desktop/DDGF_Project/AFLplusplus/utils/aflpp_driver/aflpp_driver.c:300:10
    #9 0x7fa45548d082 in __libc_start_main /build/glibc-wuryBv/glibc-2.31/csu/../csu/libc-start.c:308:16
    #10 0x70942d in _start (/home/fuzz/Desktop/DDGF_Project/OSS-Test/ImageMagick/oss-fuzz/rotate_fuzzer.new1+0x70942d)

0x606000002f3c is located 4 bytes to the right of 56-byte region [0x606000002f00,0x606000002f38)
freed by thread T0 here:
    #0 0x7b8197 in __interceptor_cfree.part.0 /home/fuzz/Desktop/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:52:3
    #1 0xb8a499 in RelinquishMagickMemory /home/fuzz/Desktop/DDGF_Project/OSS-Test/ImageMagick/MagickCore/memory.c:1167:3

previously allocated by thread T0 here:
    #0 0x7b8fb7 in malloc /home/fuzz/Desktop/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:69:3
    #1 0xb890f2 in AcquireMagickMemory /home/fuzz/Desktop/DDGF_Project/OSS-Test/ImageMagick/MagickCore/memory.c:558:10
    #2 0xb890f2 in AcquireCriticalMemory /home/fuzz/Desktop/DDGF_Project/OSS-Test/ImageMagick/MagickCore/memory.c:634:10
    #3 0xc47543 in IsRightsAuthorized /home/fuzz/Desktop/DDGF_Project/OSS-Test/ImageMagick/MagickCore/policy.c:655:8

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/fuzz/Desktop/DDGF_Project/OSS-Test/mylibs/openjpeg/src/lib/openjp2/jp2.c:2875:37 in opj_jp2_read_header
Shadow bytes around the buggy address:
  0x0c0c7fff8590: fd fd fd fa fa fa fa fa fd fd fd fd fd fd fd fa
  0x0c0c7fff85a0: fa fa fa fa fd fd fd fd fd fd fd fa fa fa fa fa
  0x0c0c7fff85b0: fd fd fd fd fd fd fd fa fa fa fa fa fd fd fd fd
  0x0c0c7fff85c0: fd fd fd fa fa fa fa fa fd fd fd fd fd fd fd fa
  0x0c0c7fff85d0: fa fa fa fa fd fd fd fd fd fd fd fa fa fa fa fa
=>0x0c0c7fff85e0: fd fd fd fd fd fd fd[fa]fa fa fa fa fd fd fd fd
  0x0c0c7fff85f0: fd fd fd fa fa fa fa fa fd fd fd fd fd fd fd fa
  0x0c0c7fff8600: fa fa fa fa fd fd fd fd fd fd fd fa fa fa fa fa
  0x0c0c7fff8610: fd fd fd fd fd fd fd fa fa fa fa fa fd fd fd fd
  0x0c0c7fff8620: fd fd fd fa fa fa fa fa fd fd fd fd fd fd fd fa
  0x0c0c7fff8630: fa fa fa fa fd fd fd fd fd fd fd fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==41886==ABORTING
```

### Steps to Reproduce

1. compile the oss-fuzz target
2. run the fuzz target with poc.  [rotate_poc.zip](https://github.com/ImageMagick/ImageMagick/files/14995709/rotate_poc.zip)

```
./rotate_fuzzer ./poc
```

### Images

_No response_
heap-buffer-overflow
This is a GitHub Issue
repo:ImageMagick
owner:ImageMagick
Title : heap-buffer-overflow
Issue date:

--- start body ---
### ImageMagick version

7.1.1-30

### Operating system

Linux

### Operating system, version and so on

Ubuntu 20.04 LTS

### Description

```
./rotate_fuzzer  ./out_rotate_crash/default/crashes/id\:000000\,sig\:06\,src\:016175+01
3217_time\:36400038_execs\:207091_op\:splice_rep\:16 
Reading 537 bytes from ./out_rotate_crash/default/crashes/id:000000,sig:06,src:016175+013217_time:36400038_execs:207091_op:splice_rep:16
=================================================================
==41886==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x606000002f3c at pc 0x000001b223d4 bp 0x7ffe5bca4120 sp 0x7ffe5bca4118
WRITE of size 4 at 0x606000002f3c thread T0
    #0 0x1b223d3 in opj_jp2_read_header /home/fuzz/Desktop/DDGF_Project/OSS-Test/mylibs/openjpeg/src/lib/openjp2/jp2.c:2875:37
    #1 0x135795e in ReadJP2Image /home/fuzz/Desktop/DDGF_Project/OSS-Test/ImageMagick/coders/jp2.c:359:7
    #2 0x9c90d4 in ReadImage /home/fuzz/Desktop/DDGF_Project/OSS-Test/ImageMagick/MagickCore/constitute.c:736:15
    #3 0x9439d5 in BlobToImage /home/fuzz/Desktop/DDGF_Project/OSS-Test/ImageMagick/MagickCore/blob.c:479:13
    #4 0x8190b1 in Magick::Image::read(Magick::Blob const&) /home/fuzz/Desktop/DDGF_Project/OSS-Test/ImageMagick/Magick++/lib/Image.cpp:4044:12
    #5 0x37a3006 in LLVMFuzzerTestOneInput /home/fuzz/Desktop/DDGF_Project/OSS-Test/ImageMagick/oss-fuzz/rotate_fuzzer.cc:42:11
    #6 0x8015dd in ExecuteFilesOnyByOne /home/fuzz/Desktop/DDGF_Project/AFLplusplus/utils/aflpp_driver/aflpp_driver.c:255:7
    #7 0x8013e8 in LLVMFuzzerRunDriver /home/fuzz/Desktop/DDGF_Project/AFLplusplus/utils/aflpp_driver/aflpp_driver.c
    #8 0x800fa8 in main /home/fuzz/Desktop/DDGF_Project/AFLplusplus/utils/aflpp_driver/aflpp_driver.c:300:10
    #9 0x7fa45548d082 in __libc_start_main /build/glibc-wuryBv/glibc-2.31/csu/../csu/libc-start.c:308:16
    #10 0x70942d in _start (/home/fuzz/Desktop/DDGF_Project/OSS-Test/ImageMagick/oss-fuzz/rotate_fuzzer.new1+0x70942d)

0x606000002f3c is located 4 bytes to the right of 56-byte region [0x606000002f00,0x606000002f38)
freed by thread T0 here:
    #0 0x7b8197 in __interceptor_cfree.part.0 /home/fuzz/Desktop/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:52:3
    #1 0xb8a499 in RelinquishMagickMemory /home/fuzz/Desktop/DDGF_Project/OSS-Test/ImageMagick/MagickCore/memory.c:1167:3

previously allocated by thread T0 here:
    #0 0x7b8fb7 in malloc /home/fuzz/Desktop/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:69:3
    #1 0xb890f2 in AcquireMagickMemory /home/fuzz/Desktop/DDGF_Project/OSS-Test/ImageMagick/MagickCore/memory.c:558:10
    #2 0xb890f2 in AcquireCriticalMemory /home/fuzz/Desktop/DDGF_Project/OSS-Test/ImageMagick/MagickCore/memory.c:634:10
    #3 0xc47543 in IsRightsAuthorized /home/fuzz/Desktop/DDGF_Project/OSS-Test/ImageMagick/MagickCore/policy.c:655:8

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/fuzz/Desktop/DDGF_Project/OSS-Test/mylibs/openjpeg/src/lib/openjp2/jp2.c:2875:37 in opj_jp2_read_header
Shadow bytes around the buggy address:
  0x0c0c7fff8590: fd fd fd fa fa fa fa fa fd fd fd fd fd fd fd fa
  0x0c0c7fff85a0: fa fa fa fa fd fd fd fd fd fd fd fa fa fa fa fa
  0x0c0c7fff85b0: fd fd fd fd fd fd fd fa fa fa fa fa fd fd fd fd
  0x0c0c7fff85c0: fd fd fd fa fa fa fa fa fd fd fd fd fd fd fd fa
  0x0c0c7fff85d0: fa fa fa fa fd fd fd fd fd fd fd fa fa fa fa fa
=>0x0c0c7fff85e0: fd fd fd fd fd fd fd[fa]fa fa fa fa fd fd fd fd
  0x0c0c7fff85f0: fd fd fd fa fa fa fa fa fd fd fd fd fd fd fd fa
  0x0c0c7fff8600: fa fa fa fa fd fd fd fd fd fd fd fa fa fa fa fa
  0x0c0c7fff8610: fd fd fd fd fd fd fd fa fa fa fa fa fd fd fd fd
  0x0c0c7fff8620: fd fd fd fa fa fa fa fa fd fd fd fd fd fd fd fa
  0x0c0c7fff8630: fa fa fa fa fd fd fd fd fd fd fd fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==41886==ABORTING
```

### Steps to Reproduce

1. compile the oss-fuzz target
2. run the fuzz target with poc.  [rotate_poc.zip](https://github.com/ImageMagick/ImageMagick/files/14995709/rotate_poc.zip)

```
./rotate_fuzzer ./poc
```

### Images

_No response_
--- end body ---
