You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
853 B
37 lines
853 B
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
#include "dng_exceptions.h"
|
|
#include "dng_host.h"
|
|
#include "dng_info.h"
|
|
#include "dng_memory_stream.h"
|
|
#include "dng_negative.h"
|
|
|
|
|
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|
dng_host host;
|
|
dng_memory_stream stream(host.Allocator());
|
|
|
|
stream.Put(data, size);
|
|
stream.SetReadPosition(0);
|
|
|
|
std::unique_ptr<dng_negative> negative(host.Make_dng_negative());
|
|
|
|
try {
|
|
dng_info info;
|
|
info.Parse(host, stream);
|
|
info.PostParse(host);
|
|
|
|
if (info.IsValidDNG()) {
|
|
negative->Parse(host, stream, info);
|
|
negative->PostParse(host, stream, info);
|
|
negative->ReadStage1Image(host, stream, info);
|
|
}
|
|
} catch (dng_exception &e) {
|
|
// dng_sdk throws C++ exceptions on errors
|
|
// catch them here to prevent libFuzzer from crashing.
|
|
}
|
|
|
|
return 0;
|
|
}
|