Add fmemopen_unlocked() and use unlocked ops in fuzzers and some other tests
This might make things marginially faster. I didn't benchmark though.
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "bus-dump.h"
|
||||
#include "bus-message.h"
|
||||
#include "env-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "fuzz.h"
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
@@ -36,7 +34,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
TAKE_PTR(buffer);
|
||||
|
||||
if (getenv_bool("SYSTEMD_FUZZ_OUTPUT") <= 0)
|
||||
assert_se(g = open_memstream(&out, &out_size));
|
||||
assert_se(g = open_memstream_unlocked(&out, &out_size));
|
||||
|
||||
bus_message_dump(m, g ?: stdout, BUS_MESSAGE_DUMP_WITH_HEADER);
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "env-file.h"
|
||||
#include "fileio.h"
|
||||
#include "fd-util.h"
|
||||
#include "fuzz.h"
|
||||
#include "strv.h"
|
||||
@@ -15,7 +16,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
if (size == 0 || size > 65535)
|
||||
return 0;
|
||||
|
||||
f = fmemopen((char*) data, size, "re");
|
||||
f = fmemopen_unlocked((char*) data, size, "re");
|
||||
assert_se(f);
|
||||
|
||||
/* We don't want to fill the logs with messages about parse errors.
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "fuzz.h"
|
||||
#include "hostname-util.h"
|
||||
|
||||
@@ -14,7 +13,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
if (size == 0)
|
||||
return 0;
|
||||
|
||||
f = fmemopen((char*) data, size, "re");
|
||||
f = fmemopen_unlocked((char*) data, size, "re");
|
||||
assert_se(f);
|
||||
|
||||
/* We don't want to fill the logs with messages about parse errors.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "fileio.h"
|
||||
#include "fd-util.h"
|
||||
#include "fuzz.h"
|
||||
#include "json.h"
|
||||
@@ -14,13 +15,13 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
if (size == 0)
|
||||
return 0;
|
||||
|
||||
f = fmemopen((char*) data, size, "re");
|
||||
f = fmemopen_unlocked((char*) data, size, "re");
|
||||
assert_se(f);
|
||||
|
||||
if (json_parse_file(f, NULL, &v, NULL, NULL) < 0)
|
||||
return 0;
|
||||
|
||||
g = open_memstream(&out, &out_size);
|
||||
g = open_memstream_unlocked(&out, &out_size);
|
||||
assert_se(g);
|
||||
|
||||
json_variant_dump(v, 0, g, NULL);
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "fuzz.h"
|
||||
#include "nspawn-oci.h"
|
||||
|
||||
@@ -14,7 +13,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
if (size == 0)
|
||||
return 0;
|
||||
|
||||
f = fmemopen((char*) data, size, "re");
|
||||
f = fmemopen_unlocked((char*) data, size, "re");
|
||||
assert_se(f);
|
||||
|
||||
/* We don't want to fill the logs with messages about parse errors.
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "fuzz.h"
|
||||
#include "nspawn-settings.h"
|
||||
|
||||
@@ -14,7 +13,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
if (size == 0)
|
||||
return 0;
|
||||
|
||||
f = fmemopen((char*) data, size, "re");
|
||||
f = fmemopen_unlocked((char*) data, size, "re");
|
||||
assert_se(f);
|
||||
|
||||
/* We don't want to fill the logs with messages about parse errors.
|
||||
|
||||
@@ -24,7 +24,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
if (size == 0)
|
||||
return 0;
|
||||
|
||||
f = fmemopen((char*) data, size, "re");
|
||||
f = fmemopen_unlocked((char*) data, size, "re");
|
||||
assert_se(f);
|
||||
|
||||
if (read_line(f, LINE_MAX, &p) < 0)
|
||||
@@ -75,7 +75,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
config_item_perf_lookup, load_fragment_gperf_lookup,
|
||||
CONFIG_PARSE_ALLOW_INCLUDE, u);
|
||||
|
||||
g = open_memstream(&out, &out_size);
|
||||
g = open_memstream_unlocked(&out, &out_size);
|
||||
assert_se(g);
|
||||
|
||||
unit_dump(u, g, "");
|
||||
|
||||
Reference in New Issue
Block a user