Skip to content

Commit 24b5472

Browse files
committed
fix: Ensure we have allocators available for the error paths.
1 parent 48dbcfe commit 24b5472

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
619d28e6ecd0dbfbf8727753d44aa7eb1d8baa53cfcd4067f426141b4c132784 /usr/local/bin/tox-bootstrapd
1+
bd6954cbbff8d2b6cc1fe5681a016ff42a0400da35c2b50d11550443c8dce6af /usr/local/bin/tox-bootstrapd

testing/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ sh_test(
1515
args = ["$(locations %s)" % f for f in CIMPLE_FILES] + [
1616
"-Wno-boolean-return",
1717
"-Wno-callback-names",
18-
"-Wno-callgraph",
1918
"-Wno-enum-names",
20-
"-Wno-type-check",
2119
"+RTS",
2220
"-N3",
2321
"-RTS",

testing/fuzzing/bootstrap_harness.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ void setup_callbacks(Tox_Dispatch *dispatch)
107107

108108
void TestBootstrap(Fuzz_Data &input)
109109
{
110+
// Null system for regularly working memory allocations needed in
111+
// tox_events_equal.
112+
Null_System null_sys;
110113
Fuzz_System sys(input);
111114

112115
Ptr<Tox_Options> opts(tox_options_new(nullptr), tox_options_free);
@@ -154,11 +157,9 @@ void TestBootstrap(Fuzz_Data &input)
154157

155158
uint8_t pub_key[TOX_PUBLIC_KEY_SIZE] = {0};
156159

157-
const bool udp_success = tox_bootstrap(tox, "127.0.0.2", 33446, pub_key, nullptr);
158-
assert(udp_success);
159-
160-
const bool tcp_success = tox_add_tcp_relay(tox, "127.0.0.2", 33446, pub_key, nullptr);
161-
assert(tcp_success);
160+
// These may fail, but that's ok. We ignore their return values.
161+
tox_bootstrap(tox, "127.0.0.2", 33446, pub_key, nullptr);
162+
tox_add_tcp_relay(tox, "127.0.0.2", 33446, pub_key, nullptr);
162163

163164
tox_events_init(tox);
164165

@@ -169,7 +170,7 @@ void TestBootstrap(Fuzz_Data &input)
169170
while (input.size > 0) {
170171
Tox_Err_Events_Iterate error_iterate;
171172
Tox_Events *events = tox_events_iterate(tox, true, &error_iterate);
172-
assert(tox_events_equal(sys.sys.get(), events, events));
173+
assert(tox_events_equal(null_sys.sys.get(), events, events));
173174
tox_dispatch_invoke(dispatch, events, tox, nullptr);
174175
tox_events_free(events);
175176
// Move the clock forward a decent amount so all the time-based checks

toxcore/group_chats.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7483,6 +7483,10 @@ int gc_group_load(GC_Session *c, Bin_Unpack *bu)
74837483
chat->last_ping_interval = tm;
74847484
chat->friend_connection_id = -1;
74857485

7486+
// Initialise these first, because we may need to log/dealloc things on cleanup.
7487+
chat->moderation.log = m->log;
7488+
chat->moderation.mem = m->mem;
7489+
74867490
if (!gc_load_unpack_group(chat, bu)) {
74877491
LOGGER_ERROR(chat->log, "Failed to unpack group");
74887492
return -1;

toxcore/network.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1772,6 +1772,9 @@ int32_t net_getipport(const Memory *mem, const char *node, IP_Port **res, int to
17721772
{
17731773
// Try parsing as IP address first.
17741774
IP_Port parsed = {{{0}}};
1775+
// Initialise to nullptr. In error paths, at least we initialise the out
1776+
// parameter.
1777+
*res = nullptr;
17751778

17761779
if (addr_parse_ip(node, &parsed.ip)) {
17771780
IP_Port *tmp = (IP_Port *)mem_alloc(mem, sizeof(IP_Port));
@@ -1800,7 +1803,6 @@ int32_t net_getipport(const Memory *mem, const char *node, IP_Port **res, int to
18001803
// It's not an IP address, so now we try doing a DNS lookup.
18011804
struct addrinfo *infos;
18021805
const int ret = getaddrinfo(node, nullptr, nullptr, &infos);
1803-
*res = nullptr;
18041806

18051807
if (ret != 0) {
18061808
return -1;

0 commit comments

Comments
 (0)