summaryrefslogtreecommitdiffstats
path: root/src/fuzz
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2023-05-26 08:40:12 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2023-05-31 23:48:47 +0200
commit2485b7e2b8a66504e0b6f3bfd03dd48ea5629497 (patch)
tree8d692db73011acb203f8650f8843e8750a217aa0 /src/fuzz
parentutil: introduce memstream-util (diff)
downloadsystemd-2485b7e2b8a66504e0b6f3bfd03dd48ea5629497.tar.xz
systemd-2485b7e2b8a66504e0b6f3bfd03dd48ea5629497.zip
tree-wide: use memstream-util
Diffstat (limited to 'src/fuzz')
-rw-r--r--src/fuzz/fuzz-json.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/fuzz/fuzz-json.c b/src/fuzz/fuzz-json.c
index c393fcf394..b2cca78501 100644
--- a/src/fuzz/fuzz-json.c
+++ b/src/fuzz/fuzz-json.c
@@ -5,12 +5,13 @@
#include "fd-util.h"
#include "fuzz.h"
#include "json.h"
+#include "memstream-util.h"
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
- _cleanup_free_ char *out = NULL; /* out should be freed after g */
- size_t out_size;
- _cleanup_fclose_ FILE *f = NULL, *g = NULL;
+ _cleanup_(memstream_done) MemStream m = {};
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
+ _cleanup_fclose_ FILE *f = NULL;
+ FILE *g = NULL;
int r;
/* Disable most logging if not running standalone */
@@ -27,7 +28,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
if (getenv_bool("SYSTEMD_FUZZ_OUTPUT") <= 0)
- assert_se(g = open_memstream_unlocked(&out, &out_size));
+ assert_se(g = memstream_init(&m));
json_variant_dump(v, 0, g ?: stdout, NULL);
json_variant_dump(v, JSON_FORMAT_PRETTY|JSON_FORMAT_COLOR|JSON_FORMAT_SOURCE, g ?: stdout, NULL);