| 1 | /* |
| 2 | Copyright @ 2026 ImageMagick Studio LLC, a non-profit organization |
| 3 | dedicated to making software imaging solutions freely available. |
| 4 | |
| 5 | You may not use this file except in compliance with the License. You may |
| 6 | obtain a copy of the License at |
| 7 | |
| 8 | https://imagemagick.org/license/ |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include <cstdint> |
| 18 | |
| 19 | #include <Magick++/Blob.h> |
| 20 | #include <Magick++/Image.h> |
| 21 | |
| 22 | #include "utils.cc" |
| 23 | |
| 24 | static const char *profileNames[] = { |
| 25 | "exif", "xmp", "iptc", "icc", "8bim", "app1", "app13" |
| 26 | }; |
| 27 | |
| 28 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data,size_t Size) |
| 29 | { |
| 30 | if (IsInvalidSize(Size,2)) |
| 31 | return(0); |
| 32 | |
| 33 | const unsigned int profileIndex=Data[0]; |
| 34 | if (profileIndex >= sizeof(profileNames) / sizeof(*profileNames)) |
| 35 | return(0); |
| 36 | const Magick::Blob blob(Data + 1, Size - 1); |
| 37 | |
| 38 | try |
| 39 | { |
| 40 | Magick::Image image("16x16","white"); |
| 41 | image.profile(profileNames[profileIndex],blob); |
| 42 | } |
| 43 | #if defined(BUILD_MAIN) |
| 44 | catch (Magick::Exception &e) |
| 45 | { |
| 46 | std::cout << "Exception when reading profile: " << e.what() << std::endl; |
| 47 | } |
| 48 | #else |
| 49 | catch (Magick::Exception) |
| 50 | { |
| 51 | } |
| 52 | #endif |
| 53 | return(0); |
| 54 | } |