2019-07-27 19:44:18 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sndfile.h>
|
2020-10-22 09:10:12 +00:00
|
|
|
#include <inttypes.h>
|
2019-07-27 19:44:18 +00:00
|
|
|
|
2021-08-15 04:38:48 +00:00
|
|
|
#include "sndfile_fuzz_header.h"
|
2019-07-27 19:44:18 +00:00
|
|
|
|
|
|
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
2021-08-15 04:38:48 +00:00
|
|
|
{ VIO_DATA vio_data ;
|
|
|
|
SF_VIRTUAL_IO vio ;
|
|
|
|
SF_INFO sndfile_info ;
|
|
|
|
SNDFILE *sndfile = NULL ;
|
|
|
|
float* read_buffer = NULL ;
|
|
|
|
|
|
|
|
int err = sf_init_file(data, size, &sndfile, &vio_data, &vio, &sndfile_info) ;
|
|
|
|
if (err)
|
|
|
|
goto EXIT_LABEL ;
|
|
|
|
|
|
|
|
// Just the right number of channels. Create some buffer space for reading.
|
|
|
|
read_buffer = (float*)malloc(sizeof(float) * sndfile_info.channels);
|
|
|
|
if (read_buffer == NULL)
|
|
|
|
abort() ;
|
|
|
|
|
|
|
|
while (sf_readf_float(sndfile, read_buffer, 1))
|
|
|
|
{
|
|
|
|
// Do nothing with the data.
|
|
|
|
}
|
2019-07-27 19:44:18 +00:00
|
|
|
|
|
|
|
EXIT_LABEL:
|
|
|
|
|
2021-08-15 04:38:48 +00:00
|
|
|
if (sndfile != NULL)
|
|
|
|
sf_close(sndfile) ;
|
2019-07-27 19:44:18 +00:00
|
|
|
|
2021-08-15 04:38:48 +00:00
|
|
|
free(read_buffer) ;
|
2019-07-27 19:44:18 +00:00
|
|
|
|
2021-08-15 04:38:48 +00:00
|
|
|
return 0 ;
|
2019-07-27 19:44:18 +00:00
|
|
|
}
|