Skip to content

Commit

Permalink
Temporary workaround for a double close crash with fdsan.
Browse files Browse the repository at this point in the history
  • Loading branch information
grote authored and bitmold committed Apr 7, 2024
1 parent cd23e61 commit 517d241
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/feature/api/org_torproject_jni_TorService.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ Java_org_torproject_jni_TorService_mainConfigurationFree
fprintf(stderr, "ConfigurationFree: The Tor configuration is NULL!\n");
return;
}
unset_owning_controller_socket(cfg);
tor_main_configuration_free(cfg);
}

Expand Down
11 changes: 11 additions & 0 deletions src/feature/api/tor_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ tor_main_configuration_set_command_line(tor_main_configuration_t *cfg,
return 0;
}

/*
* Temporary workaround for a double close crash with fdsan.
* See: https://github.com/guardianproject/tor-android/issues/57
* Should be removed once fixed in Tor upstream.
*/
void
unset_owning_controller_socket(tor_main_configuration_t* t)
{
t->owning_controller_socket = -1;
}

tor_control_socket_t
tor_main_configuration_setup_control_socket(tor_main_configuration_t *cfg)
{
Expand Down
7 changes: 7 additions & 0 deletions src/feature/api/tor_api_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,11 @@ struct tor_main_configuration_t {
tor_socket_t owning_controller_socket;
};

/*
* Temporary workaround for a double close crash with fdsan.
* See: https://github.com/guardianproject/tor-android/issues/57
* Should be removed once fixed in Tor upstream.
*/
void unset_owning_controller_socket(tor_main_configuration_t* t);

#endif /* !defined(TOR_API_INTERNAL_H) */

0 comments on commit 517d241

Please sign in to comment.