File: stbi_read_fuzzer.c

package info (click to toggle)
libstb 0.0~git20220908.8b5f1f3%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 6,292 kB
  • sloc: ansic: 68,653; cpp: 1,501; makefile: 113; sh: 22
file content (28 lines) | stat: -rw-r--r-- 502 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#ifdef __cplusplus
extern "C" {
#endif

#define STB_IMAGE_IMPLEMENTATION

#include "../stb_image.h"


int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
    int x, y, channels;

    if(!stbi_info_from_memory(data, size, &x, &y, &channels)) return 0;

    /* exit if the image is larger than ~80MB */
    if(y && x > (80000000 / 4) / y) return 0;

    unsigned char *img = stbi_load_from_memory(data, size, &x, &y, &channels, 4);

    free(img);

    return 0;
}

#ifdef __cplusplus
}
#endif