A vulnerability was found in ImageMagick. This security flaw ouccers as an undefined behaviors of casting double to size_t in svg, mvg and other coders (recurring bugs of CVE-2022-32546).
### ImageMagick version

7.1.30-0

### Operating system

Linux

### Operating system, version and so on

Any

### Description

While reviewing historical vulnerabilities, I discovered several similar bugs just like issue #4985 which was later assigned CVE-2022-32546.

The original vulnerability relates to casting a width/height value in `double` to `size_t` or `unsigned long`, which denotes columns/rows number in pixels. The issue concerns about PCL format, and the fix (#4986 ) was about PCL only.

However, with a CodeQL rule, I am able to find almost the same issues in several other readers `ReadXXXImage` functions, like CAPTION, EMF, LABEL, MVG, PS, PS2, PS3, SVG, WMF. It was easy to construct sample mvg and svg files to trigger these bugs, as shown below.

### Steps to Reproduce

#### Prerequisite

configure ImageMagick with UBSAN. If compiled with gcc, specifically turn on `flow-cast-overflow`:

```bash
./configure CFLAGS='-g -fsanitize=address,undefined,float-cast-overflow -fsanitize-recover=address,undefined,float-cast-overflow' LDFLAGS='-fsanitize=address,undefined,float-cast-overflow -lasan -lubsan'
```

#### Trigger

Use the malformed sample files in the attached zip. The following commands demonstrates the bugs.

```bash
/data/home/fullwaywang/exp
➜ magick identify bitcoin.svg
coders/svg.c:2829:38: runtime error: 5e+24 is outside the range of representable values of type 'long unsigned int'
bitcoin.svg SVG 0x234 0x234+0+0 16-bit sRGB 19056B 0.010u 0:00.015

/data/home/fullwaywang/exp
➜ magick identify mvg:piechart.mvg
coders/mvg.c:180:33: runtime error: 5e+26 is outside the range of representable values of type 'long unsigned int'
identify: MustSpecifyImageSize `piechart.mvg' @ error/mvg.c/ReadMVGImage/186.
```


### Images

[samples.zip](https://github.com/ImageMagick/ImageMagick/files/11497437/samples.zip)

### Reporter

fullwaywang
Undefined behaviors of casting `double` to `size_t` in svg, mvg and other coders (recurring bugs of CVE-2022-32546)
This is a GitHub Issue
repo:ImageMagick
owner:ImageMagick
Title : Undefined behaviors of casting `double` to `size_t` in svg, mvg and other coders (recurring bugs of CVE-2022-32546)
Issue date:

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

7.1.30-0

### Operating system

Linux

### Operating system, version and so on

Any

### Description

While reviewing historical vulnerabilities, I discovered several similar bugs just like issue #4985 which was later assigned CVE-2022-32546.

The original vulnerability relates to casting a width/height value in `double` to `size_t` or `unsigned long`, which denotes columns/rows number in pixels. The issue concerns about PCL format, and the fix (#4986 ) was about PCL only.

However, with a CodeQL rule, I am able to find almost the same issues in several other readers `ReadXXXImage` functions, like CAPTION, EMF, LABEL, MVG, PS, PS2, PS3, SVG, WMF. It was easy to construct sample mvg and svg files to trigger these bugs, as shown below.

### Steps to Reproduce

#### Prerequisite

configure ImageMagick with UBSAN. If compiled with gcc, specifically turn on `flow-cast-overflow`:

```bash
./configure CFLAGS='-g -fsanitize=address,undefined,float-cast-overflow -fsanitize-recover=address,undefined,float-cast-overflow' LDFLAGS='-fsanitize=address,undefined,float-cast-overflow -lasan -lubsan'
```

#### Trigger

Use the malformed sample files in the attached zip. The following commands demonstrates the bugs.

```bash
/data/home/fullwaywang/exp
➜ magick identify bitcoin.svg
coders/svg.c:2829:38: runtime error: 5e+24 is outside the range of representable values of type 'long unsigned int'
bitcoin.svg SVG 0x234 0x234+0+0 16-bit sRGB 19056B 0.010u 0:00.015

/data/home/fullwaywang/exp
➜ magick identify mvg:piechart.mvg
coders/mvg.c:180:33: runtime error: 5e+26 is outside the range of representable values of type 'long unsigned int'
identify: MustSpecifyImageSize `piechart.mvg' @ error/mvg.c/ReadMVGImage/186.
```


### Images

[samples.zip](https://github.com/ImageMagick/ImageMagick/files/11497437/samples.zip)

### Reporter

fullwaywang
--- end body ---
