+ +
2da5fe7 OpenAVX v0.2.0 - High-performance open-standard IP audio and video transport suite
saifmukhtar · 2026-11-24
main
| 1 | /* |
| 2 | * SPDX-License-Identifier: AGPL-3.0-or-later WITH Classpath-exception-2.0 |
| 3 | * Copyright (c) 2026 Saif Mukhtar |
| 4 | * |
| 5 | * OpenAVX - Open Audio-Video eXchange |
| 6 | * fuzz/fuzz_hdr_xml.c - libFuzzer Target for HDR & Color Metadata XML Parser |
| 7 | */ |
| 8 | |
| 9 | #include <stdint.h> |
| 10 | #include <stddef.h> |
| 11 | #include <stdlib.h> |
| 12 | #include <string.h> |
| 13 | #include "avx_hdr.h" |
| 14 | |
| 15 | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { |
| 16 | if (!data || size == 0) return 0; |
| 17 | |
| 18 | /* Ensure payload is null-terminated */ |
| 19 | char *xml_str = (char *)malloc(size + 1); |
| 20 | if (!xml_str) return 0; |
| 21 | memcpy(xml_str, data, size); |
| 22 | xml_str[size] = '\0'; |
| 23 | |
| 24 | avx_color_info_t info; |
| 25 | if (avx_hdr_parse_color_info(xml_str, &info)) { |
| 26 | (void)avx_hdr_is_hdr(&info); |
| 27 | |
| 28 | char out_xml[512]; |
| 29 | (void)avx_hdr_format_color_info(&info, out_xml, sizeof(out_xml)); |
| 30 | |
| 31 | /* Verify frame helpers */ |
| 32 | oavx_video_frame_t frame; |
| 33 | memset(&frame, 0, sizeof(frame)); |
| 34 | char xml_buf[512]; |
| 35 | if (avx_hdr_frame_set_color_info(&frame, &info, xml_buf, sizeof(xml_buf))) { |
| 36 | avx_color_info_t parsed_info; |
| 37 | (void)avx_hdr_frame_get_color_info(&frame, &parsed_info); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | free(xml_str); |
| 42 | return 0; |
| 43 | } |