Skip to content

Commit

Permalink
devtools: call common_setup in main
Browse files Browse the repository at this point in the history
Fixes nullability errors detected by UBSan:

wire/fromwire.c:173:46: runtime error: null pointer passed as argument 1, which is declared to never be null
external/libwally-core/src/secp256k1/include/secp256k1.h:432:3: note: nonnull attribute specified here
    #0 0x65214a in fromwire_secp256k1_ecdsa_signature wire/fromwire.c:173:6
    #1 0x659500 in printwire_secp256k1_ecdsa_signature devtools/print_wire.c:331:1
    #2 0x646ba2 in printwire_channel_update wire/peer_printgen.c:1900:7
    #3 0x637182 in printpeer_wire_message wire/peer_printgen.c:128:11
    #4 0x65a097 in main devtools/decodemsg.c:85:10
  • Loading branch information
morehouse authored and cdecker committed Jun 5, 2023
1 parent 3edb092 commit e81bf8b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions devtools/decodemsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <ccan/err/err.h>
#include <ccan/opt/opt.h>
#include <ccan/tal/grab_file/grab_file.h>
#include <common/setup.h>
#include <unistd.h>
#include <wire/onion_printgen.h>
#include <wire/peer_printgen.h>
Expand Down Expand Up @@ -50,6 +51,7 @@ int main(int argc, char *argv[])
bool (*printwire)(const u8 *msg) = printpeer_wire_message;
bool ok = true;

common_setup(argv[0]);
setup_locale();

opt_register_noarg("--onion", opt_set_onionprint, &printwire,
Expand Down
3 changes: 3 additions & 0 deletions devtools/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <common/dijkstra.h>
#include <common/gossmap.h>
#include <common/route.h>
#include <common/setup.h>
#include <common/type_to_string.h>
#include <devtools/clean_topo.h>
#include <inttypes.h>
Expand Down Expand Up @@ -70,6 +71,8 @@ int main(int argc, char *argv[])
bool clean_topology = false;
size_t num_channel_updates_rejected;

common_setup(argv[0]);

opt_register_noarg("--clean-topology", opt_set_bool, &clean_topology,
"Clean up topology before run");
opt_register_noarg("-h|--help", opt_usage_and_exit,
Expand Down

0 comments on commit e81bf8b

Please sign in to comment.