mirror of https://github.com/google/oss-fuzz.git
69 lines
2.0 KiB
C++
69 lines
2.0 KiB
C++
/* Copyright 2021 Google LLC
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <sys/types.h>
|
|
#include <unistd.h>
|
|
|
|
#include "dng_color_space.h"
|
|
#include "dng_date_time.h"
|
|
#include "dng_exceptions.h"
|
|
#include "dng_file_stream.h"
|
|
#include "dng_globals.h"
|
|
#include "dng_host.h"
|
|
#include "dng_ifd.h"
|
|
#include "dng_image_writer.h"
|
|
#include "dng_info.h"
|
|
#include "dng_linearization_info.h"
|
|
#include "dng_mosaic_info.h"
|
|
#include "dng_negative.h"
|
|
#include "dng_preview.h"
|
|
#include "dng_render.h"
|
|
#include "dng_simple_image.h"
|
|
#include "dng_tag_codes.h"
|
|
#include "dng_tag_types.h"
|
|
#include "dng_tag_values.h"
|
|
#include "dng_camera_profile.h"
|
|
|
|
#include <fuzzer/FuzzedDataProvider.h>
|
|
|
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|
FuzzedDataProvider provider(data, size);
|
|
std::string s1 = provider.ConsumeRandomLengthString();
|
|
|
|
char filename[256];
|
|
sprintf(filename, "/tmp/libfuzzer.%d", getpid());
|
|
FILE *fp = fopen(filename, "wb");
|
|
if (!fp) {
|
|
return 0;
|
|
}
|
|
fwrite(s1.c_str(), s1.size(), 1, fp);
|
|
fclose(fp);
|
|
|
|
// Create a file stream
|
|
dng_file_stream fStream(filename, false, 0);
|
|
|
|
// Create a custom camera profile based on the fstream above
|
|
try {
|
|
AutoPtr<dng_camera_profile> customCameraProfile (new dng_camera_profile ());
|
|
customCameraProfile->ParseExtended(fStream);
|
|
|
|
// The profile is not stubeed, so we can calculate the fingerprint.
|
|
const dng_fingerprint &fPrint = customCameraProfile->Fingerprint();
|
|
} catch (dng_exception &e) {}
|
|
|
|
unlink(filename);
|
|
return 0;
|
|
}
|