aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2022-12-08 20:51:35 +0900
committerMartin Schanzenbach <schanzen@gnunet.org>2022-12-08 20:51:35 +0900
commit7768a7a75ee959b53cf7a7acdfa0a8c7b17de99e (patch)
treeaaabeaa4b8e8a0afe82d8d7538d271525105da48 /src/transport
parentdccf4142eaac44711692c295d81e0103c8042cd2 (diff)
downloadgnunet-7768a7a75ee959b53cf7a7acdfa0a8c7b17de99e.tar.gz
gnunet-7768a7a75ee959b53cf7a7acdfa0a8c7b17de99e.zip
TESTING: Sanitize API. Add new GNUNET_TESTING_command_new API
This commit changes the label member of GNUNET_TRANSPORT_Command to a static, fixed length buffer allocated with the struct itself. The check for the end of a command array should be done by checking the run command instead of the label.
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/transport_api_cmd_backchannel_check.c16
-rw-r--r--src/transport/transport_api_cmd_connecting_peers.c18
-rw-r--r--src/transport/transport_api_cmd_send_simple.c14
-rw-r--r--src/transport/transport_api_cmd_start_peer.c17
-rw-r--r--src/transport/transport_api_cmd_stop_peer.c16
5 files changed, 30 insertions, 51 deletions
diff --git a/src/transport/transport_api_cmd_backchannel_check.c b/src/transport/transport_api_cmd_backchannel_check.c
index e67d9a79c..9f62281a4 100644
--- a/src/transport/transport_api_cmd_backchannel_check.c
+++ b/src/transport/transport_api_cmd_backchannel_check.c
@@ -545,14 +545,10 @@ GNUNET_TRANSPORT_cmd_backchannel_check (const char *label,
545 cs->node_n = node_n; 545 cs->node_n = node_n;
546 cs->namespace_n = namespace_n; 546 cs->namespace_n = namespace_n;
547 547
548 struct GNUNET_TESTING_Command cmd = { 548 return GNUNET_TESTING_command_new (cs,
549 .cls = cs, 549 label,
550 .label = GNUNET_strdup (label), 550 &backchannel_check_run,
551 .run = &backchannel_check_run, 551 &backchannel_check_cleanup,
552 .ac = &cs->ac, 552 &backchannel_check_traits,
553 .cleanup = &backchannel_check_cleanup, 553 &cs->ac);
554 .traits = &backchannel_check_traits
555 };
556
557 return cmd;
558} 554}
diff --git a/src/transport/transport_api_cmd_connecting_peers.c b/src/transport/transport_api_cmd_connecting_peers.c
index d610bbcb7..528e05b5f 100644
--- a/src/transport/transport_api_cmd_connecting_peers.c
+++ b/src/transport/transport_api_cmd_connecting_peers.c
@@ -251,16 +251,10 @@ GNUNET_TRANSPORT_cmd_connect_peers (const char *label,
251 cps->notify_connect = notify_connect; 251 cps->notify_connect = notify_connect;
252 cps->additional_connects = additional_connects; 252 cps->additional_connects = additional_connects;
253 253
254 { 254 return GNUNET_TESTING_command_new (cps,
255 struct GNUNET_TESTING_Command cmd = { 255 label,
256 .cls = cps, 256 &connect_peers_run,
257 .label = GNUNET_strdup (label), 257 &connect_peers_cleanup,
258 .run = &connect_peers_run, 258 &connect_peers_traits,
259 .ac = &cps->ac, 259 &cps->ac);
260 .cleanup = &connect_peers_cleanup,
261 .traits = &connect_peers_traits
262 };
263
264 return cmd;
265 }
266} 260}
diff --git a/src/transport/transport_api_cmd_send_simple.c b/src/transport/transport_api_cmd_send_simple.c
index 73edcf549..2671727c0 100644
--- a/src/transport/transport_api_cmd_send_simple.c
+++ b/src/transport/transport_api_cmd_send_simple.c
@@ -153,12 +153,10 @@ GNUNET_TRANSPORT_cmd_send_simple (const char *label,
153 sss->create_label = create_label; 153 sss->create_label = create_label;
154 sss->topology = topology; 154 sss->topology = topology;
155 155
156 struct GNUNET_TESTING_Command cmd = { 156 return GNUNET_TESTING_command_new (sss,
157 .cls = sss, 157 label,
158 .label = GNUNET_strdup (label), 158 &send_simple_run,
159 .run = &send_simple_run, 159 &send_simple_cleanup,
160 .cleanup = &send_simple_cleanup 160 NULL,
161 }; 161 NULL);
162
163 return cmd;
164} 162}
diff --git a/src/transport/transport_api_cmd_start_peer.c b/src/transport/transport_api_cmd_start_peer.c
index 7de1d842e..0677b6227 100644
--- a/src/transport/transport_api_cmd_start_peer.c
+++ b/src/transport/transport_api_cmd_start_peer.c
@@ -469,15 +469,10 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label,
469 handlers, 469 handlers,
470 i * sizeof(struct GNUNET_MQ_MessageHandler)); 470 i * sizeof(struct GNUNET_MQ_MessageHandler));
471 } 471 }
472 472 return GNUNET_TESTING_command_new (sps,
473 struct GNUNET_TESTING_Command cmd = { 473 label,
474 .cls = sps, 474 &start_peer_run,
475 .label = GNUNET_strdup (label), 475 &start_peer_cleanup,
476 .run = &start_peer_run, 476 &start_peer_traits,
477 .ac = &sps->ac, 477 &sps->ac);
478 .cleanup = &start_peer_cleanup,
479 .traits = &start_peer_traits
480 };
481
482 return cmd;
483} 478}
diff --git a/src/transport/transport_api_cmd_stop_peer.c b/src/transport/transport_api_cmd_stop_peer.c
index 04c822155..1fdd48fa6 100644
--- a/src/transport/transport_api_cmd_stop_peer.c
+++ b/src/transport/transport_api_cmd_stop_peer.c
@@ -143,14 +143,10 @@ GNUNET_TRANSPORT_cmd_stop_peer (const char *label,
143 143
144 sps = GNUNET_new (struct StopPeerState); 144 sps = GNUNET_new (struct StopPeerState);
145 sps->start_label = start_label; 145 sps->start_label = start_label;
146 { 146 return GNUNET_TESTING_command_new (sps,
147 struct GNUNET_TESTING_Command cmd = { 147 label,
148 .cls = sps, 148 &stop_peer_run,
149 .label = GNUNET_strdup (label), 149 &stop_peer_cleanup,
150 .run = &stop_peer_run, 150 &stop_peer_traits,
151 .cleanup = &stop_peer_cleanup, 151 NULL);
152 .traits = &stop_peer_traits
153 };
154 return cmd;
155 }
156} 152}