MCPcopy Create free account
hub / github.com/ElementsProject/lightning / run

Function run

tests/fuzz/fuzz-handle_onion_message.c:72–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72void run(const uint8_t *data, size_t size)
73{
74 struct daemon *daemon = NULL;
75 struct peer *peer;
76 struct pubkey dummy_key;
77
78 if (setjmp(fuzz_env) != 0)
79 goto cleanup;
80
81 memset(&dummy_key, 'c', sizeof(dummy_key));
82
83 daemon = new_daemon(tmpctx);
84 if (!daemon)
85 goto cleanup;
86
87 peer = talz(tmpctx, struct peer);
88
89 peer->daemon = daemon;
90 node_id_from_pubkey(&peer->id, &dummy_key);
91 peer->onionmsg_incoming_tokens = ONION_MSG_MSEC;
92
93 /* Use fuzzer data as payload of the onion message. */
94 const u8 *onion_msg = towire_onion_message(tmpctx, &dummy_key,
95 tal_dup_arr(tmpctx, u8, data, size, 0));
96
97 handle_onion_message(daemon, peer, onion_msg);
98
99cleanup:
100 if (daemon)
101 tal_free(daemon->master);
102 clean_tmpctx();
103}

Callers

nothing calls this directly

Calls 5

new_daemonFunction · 0.85
node_id_from_pubkeyFunction · 0.85
handle_onion_messageFunction · 0.85
tal_freeFunction · 0.85
clean_tmpctxFunction · 0.85

Tested by

no test coverage detected