Files
cryptsetup/tests/fuzz/crypt2_load_proto_plain_json_fuzz.cc
Milan Broz 661f57def4 Use SPDX license identifiers.
This patch switches code to SPDX one-line license identifiers according to
https://spdx.dev/learn/handling-license-info/
and replacing long license text headers.

I used C++ format on the first line in style
// SPDX-License-Identifier: <id>
except exported libcryptsetup.h, when only C comments are used.

The only additional changes are:
- switch backend utf8.c from LGPL2+ to LGPL2.1+ (as in systemd)
- add some additional formatting lines.
2024-06-03 16:38:15 +00:00

39 lines
963 B
C++

// SPDX-License-Identifier: GPL-2.0-or-later
/*
* cryptsetup LUKS2 custom mutator fuzz target
*
* Copyright (C) 2022-2024 Daniel Zatovic <daniel.zatovic@gmail.com>
* Copyright (C) 2022-2024 Red Hat, Inc. All rights reserved.
*/
#include "LUKS2_plain_JSON.pb.h"
#include "plain_json_proto_to_luks2_converter.h"
#include "libfuzzer/libfuzzer_macro.h"
#include "FuzzerInterface.h"
extern "C" {
#include <libcryptsetup.h>
#include <err.h>
#include <fcntl.h>
#include <unistd.h>
}
DEFINE_PROTO_FUZZER(const json_proto::LUKS2_both_headers &headers) {
struct crypt_device *cd = NULL;
char name[] = "/tmp/test-proto-fuzz.XXXXXX";
int fd = mkostemp(name, O_RDWR|O_CREAT|O_EXCL|O_CLOEXEC);
if (fd < 0)
err(EXIT_FAILURE, "mkostemp() failed");
json_proto::LUKS2ProtoConverter converter;
converter.convert(headers, fd);
if (crypt_init(&cd, name) == 0)
(void)crypt_load(cd, CRYPT_LUKS2, NULL);
crypt_free(cd);
close(fd);
unlink(name);
}