Debian Codegraph @

ossfuzz/sndfile_fuzzer.cc

raw
1 #include <stdint.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <sys/types.h>
5 #include <sndfile.h>
6 #include <inttypes.h>
7
8 #include "sndfile_fuzz_header.h"
9
10 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
11 { VIO_DATA vio_data ;
12 SF_VIRTUAL_IO vio ;
13 SF_INFO sndfile_info ;
14 SNDFILE *sndfile = NULL ;
15 float* read_buffer = NULL ;
16
17 int err = sf_init_file(data, size, &sndfile, &vio_data, &vio, &sndfile_info) ;
18 if (err)
19 goto EXIT_LABEL ;
20
21 // Just the right number of channels. Create some buffer space for reading.
22 read_buffer = (float*)malloc(sizeof(float) * sndfile_info.channels);
23 if (read_buffer == NULL)
24 abort() ;
25
26 while (sf_readf_float(sndfile, read_buffer, 1))
27 {
28 // Do nothing with the data.
29 }
30
31 EXIT_LABEL:
32
33 if (sndfile != NULL)
34 sf_close(sndfile) ;
35
36 free(read_buffer) ;
37
38 return 0 ;
39 }