diff options
author | t3sserakt <t3ss@posteo.de> | 2022-10-14 19:30:52 +0200 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2022-10-14 19:30:52 +0200 |
commit | 9a52524975f49eacae04b24643b3b0da08bdf7d3 (patch) | |
tree | 58f3efbbd0da1a760dd0306c8863a1a60fee43b6 /src/transport | |
parent | 1d57863045b4eff8146c233b6fa4e9dd8a8cc069 (diff) | |
download | gnunet-9a52524975f49eacae04b24643b3b0da08bdf7d3.tar.gz gnunet-9a52524975f49eacae04b24643b3b0da08bdf7d3.zip |
- fixing coverity findings
Diffstat (limited to 'src/transport')
7 files changed, 98 insertions, 17 deletions
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c index 2a5290bf9..74c509ec5 100644 --- a/src/transport/gnunet-communicator-tcp.c +++ b/src/transport/gnunet-communicator-tcp.c | |||
@@ -3554,6 +3554,8 @@ run (void *cls, | |||
3554 | socklen_t addr_len_ipv6; | 3554 | socklen_t addr_len_ipv6; |
3555 | 3555 | ||
3556 | (void) cls; | 3556 | (void) cls; |
3557 | memset (&v4,0,sizeof(struct sockaddr_in)); | ||
3558 | memset (&v6,0,sizeof(struct sockaddr_in6)); | ||
3557 | cfg = c; | 3559 | cfg = c; |
3558 | if (GNUNET_OK != | 3560 | if (GNUNET_OK != |
3559 | GNUNET_CONFIGURATION_get_value_string (cfg, | 3561 | GNUNET_CONFIGURATION_get_value_string (cfg, |
diff --git a/src/transport/gnunet-communicator-udp.c b/src/transport/gnunet-communicator-udp.c index 07beeac38..9ca9fb90a 100644 --- a/src/transport/gnunet-communicator-udp.c +++ b/src/transport/gnunet-communicator-udp.c | |||
@@ -2367,6 +2367,7 @@ sock_read (void *cls) | |||
2367 | { | 2367 | { |
2368 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2368 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2369 | "Received our own broadcast\n"); | 2369 | "Received our own broadcast\n"); |
2370 | GNUNET_free (addr_verify); | ||
2370 | return; | 2371 | return; |
2371 | } | 2372 | } |
2372 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2373 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
diff --git a/src/transport/test_transport_plugin_cmd_simple_send.c b/src/transport/test_transport_plugin_cmd_simple_send.c index ee6b9669b..5941a991b 100644 --- a/src/transport/test_transport_plugin_cmd_simple_send.c +++ b/src/transport/test_transport_plugin_cmd_simple_send.c | |||
@@ -113,14 +113,11 @@ handle_result (void *cls, | |||
113 | enum GNUNET_GenericReturnValue rv) | 113 | enum GNUNET_GenericReturnValue rv) |
114 | { | 114 | { |
115 | struct TestState *ts = cls; | 115 | struct TestState *ts = cls; |
116 | struct GNUNET_MessageHeader *reply; | ||
117 | 116 | ||
118 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 117 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
119 | "Local test exits with status %d\n", | 118 | "Local test exits with status %d\n", |
120 | rv); | 119 | rv); |
121 | 120 | ||
122 | reply = GNUNET_TESTING_send_local_test_finished_msg (); | ||
123 | |||
124 | ts->finished_cb (); | 121 | ts->finished_cb (); |
125 | GNUNET_free (ts->testdir); | 122 | GNUNET_free (ts->testdir); |
126 | GNUNET_free (ts->cfgname); | 123 | GNUNET_free (ts->cfgname); |
@@ -238,6 +235,7 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
238 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf"); | 235 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf"); |
239 | } | 236 | } |
240 | GNUNET_assert (0 < sscanf_ret); | 237 | GNUNET_assert (0 < sscanf_ret); |
238 | |||
241 | if (0 == n_int) | 239 | if (0 == n_int) |
242 | num = m_int; | 240 | num = m_int; |
243 | else | 241 | else |
diff --git a/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c index 6254dba36..3a282bb11 100644 --- a/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c +++ b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c | |||
@@ -226,9 +226,14 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
226 | unsigned int num; | 226 | unsigned int num; |
227 | struct TestState *ts = GNUNET_new (struct TestState); | 227 | struct TestState *ts = GNUNET_new (struct TestState); |
228 | struct GNUNET_TESTING_NetjailTopology *topology; | 228 | struct GNUNET_TESTING_NetjailTopology *topology; |
229 | 229 | unsigned int sscanf_ret = 0; | |
230 | 230 | ||
231 | ts->finished_cb = finished_cb; | 231 | ts->finished_cb = finished_cb; |
232 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
233 | "n %s m %s\n", | ||
234 | n, | ||
235 | m); | ||
236 | |||
232 | if (GNUNET_YES == *read_file) | 237 | if (GNUNET_YES == *read_file) |
233 | { | 238 | { |
234 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 239 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -240,9 +245,27 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
240 | 245 | ||
241 | ts->topology = topology; | 246 | ts->topology = topology; |
242 | 247 | ||
243 | sscanf (m, "%u", &m_int); | 248 | errno = 0; |
244 | sscanf (n, "%u", &n_int); | 249 | sscanf_ret = sscanf (m, "%u", &m_int); |
245 | sscanf (local_m, "%u", &local_m_int); | 250 | if (errno != 0) |
251 | { | ||
252 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf"); | ||
253 | } | ||
254 | GNUNET_assert (0 < sscanf_ret); | ||
255 | errno = 0; | ||
256 | sscanf_ret = sscanf (n, "%u", &n_int); | ||
257 | if (errno != 0) | ||
258 | { | ||
259 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf"); | ||
260 | } | ||
261 | GNUNET_assert (0 < sscanf_ret); | ||
262 | errno = 0; | ||
263 | sscanf_ret = sscanf (local_m, "%u", &local_m_int); | ||
264 | if (errno != 0) | ||
265 | { | ||
266 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf"); | ||
267 | } | ||
268 | GNUNET_assert (0 < sscanf_ret); | ||
246 | 269 | ||
247 | if (0 == n_int) | 270 | if (0 == n_int) |
248 | num = m_int; | 271 | num = m_int; |
diff --git a/src/transport/test_transport_plugin_cmd_simple_send_dv.c b/src/transport/test_transport_plugin_cmd_simple_send_dv.c index ea0c9aea8..8bfa1fd0a 100644 --- a/src/transport/test_transport_plugin_cmd_simple_send_dv.c +++ b/src/transport/test_transport_plugin_cmd_simple_send_dv.c | |||
@@ -256,8 +256,14 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
256 | ts), | 256 | ts), |
257 | GNUNET_MQ_handler_end () | 257 | GNUNET_MQ_handler_end () |
258 | }; | 258 | }; |
259 | unsigned int sscanf_ret = 0; | ||
259 | 260 | ||
260 | ts->finished_cb = finished_cb; | 261 | ts->finished_cb = finished_cb; |
262 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
263 | "n %s m %s\n", | ||
264 | n, | ||
265 | m); | ||
266 | |||
261 | if (GNUNET_YES == *read_file) | 267 | if (GNUNET_YES == *read_file) |
262 | { | 268 | { |
263 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 269 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -269,9 +275,27 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
269 | 275 | ||
270 | ts->topology = topology; | 276 | ts->topology = topology; |
271 | 277 | ||
272 | sscanf (m, "%u", &m_int); | 278 | errno = 0; |
273 | sscanf (n, "%u", &n_int); | 279 | sscanf_ret = sscanf (m, "%u", &m_int); |
274 | sscanf (local_m, "%u", &local_m_int); | 280 | if (errno != 0) |
281 | { | ||
282 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf"); | ||
283 | } | ||
284 | GNUNET_assert (0 < sscanf_ret); | ||
285 | errno = 0; | ||
286 | sscanf_ret = sscanf (n, "%u", &n_int); | ||
287 | if (errno != 0) | ||
288 | { | ||
289 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf"); | ||
290 | } | ||
291 | GNUNET_assert (0 < sscanf_ret); | ||
292 | errno = 0; | ||
293 | sscanf_ret = sscanf (local_m, "%u", &local_m_int); | ||
294 | if (errno != 0) | ||
295 | { | ||
296 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf"); | ||
297 | } | ||
298 | GNUNET_assert (0 < sscanf_ret); | ||
275 | 299 | ||
276 | if (0 == n_int) | 300 | if (0 == n_int) |
277 | num = m_int; | 301 | num = m_int; |
diff --git a/src/transport/test_transport_plugin_cmd_udp_backchannel.c b/src/transport/test_transport_plugin_cmd_udp_backchannel.c index 87065e340..5a0dac32b 100644 --- a/src/transport/test_transport_plugin_cmd_udp_backchannel.c +++ b/src/transport/test_transport_plugin_cmd_udp_backchannel.c | |||
@@ -34,7 +34,7 @@ | |||
34 | /** | 34 | /** |
35 | * Generic logging shortcut | 35 | * Generic logging shortcut |
36 | */ | 36 | */ |
37 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | 37 | #define LOG(kind, ...) GNUNET_log_from (kind, "udp-backchannel", __VA_ARGS__) |
38 | 38 | ||
39 | #define BASE_DIR "testdir" | 39 | #define BASE_DIR "testdir" |
40 | 40 | ||
@@ -187,18 +187,46 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
187 | unsigned int num; | 187 | unsigned int num; |
188 | struct TestState *ts = GNUNET_new (struct TestState); | 188 | struct TestState *ts = GNUNET_new (struct TestState); |
189 | struct GNUNET_TESTING_NetjailTopology *topology; | 189 | struct GNUNET_TESTING_NetjailTopology *topology; |
190 | unsigned int sscanf_ret = 0; | ||
190 | 191 | ||
191 | ts->finished_cb = finished_cb; | 192 | ts->finished_cb = finished_cb; |
193 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
194 | "n %s m %s\n", | ||
195 | n, | ||
196 | m); | ||
197 | |||
192 | if (GNUNET_YES == *read_file) | 198 | if (GNUNET_YES == *read_file) |
199 | { | ||
200 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
201 | "read from file\n"); | ||
193 | topology = GNUNET_TESTING_get_topo_from_file (topology_data); | 202 | topology = GNUNET_TESTING_get_topo_from_file (topology_data); |
203 | } | ||
194 | else | 204 | else |
195 | topology = GNUNET_TESTING_get_topo_from_string (topology_data); | 205 | topology = GNUNET_TESTING_get_topo_from_string (topology_data); |
196 | 206 | ||
197 | ts->topology = topology; | 207 | ts->topology = topology; |
198 | 208 | ||
199 | sscanf (m, "%u", &m_int); | 209 | errno = 0; |
200 | sscanf (n, "%u", &n_int); | 210 | sscanf_ret = sscanf (m, "%u", &m_int); |
201 | sscanf (local_m, "%u", &local_m_int); | 211 | if (errno != 0) |
212 | { | ||
213 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf"); | ||
214 | } | ||
215 | GNUNET_assert (0 < sscanf_ret); | ||
216 | errno = 0; | ||
217 | sscanf_ret = sscanf (n, "%u", &n_int); | ||
218 | if (errno != 0) | ||
219 | { | ||
220 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf"); | ||
221 | } | ||
222 | GNUNET_assert (0 < sscanf_ret); | ||
223 | errno = 0; | ||
224 | sscanf_ret = sscanf (local_m, "%u", &local_m_int); | ||
225 | if (errno != 0) | ||
226 | { | ||
227 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf"); | ||
228 | } | ||
229 | GNUNET_assert (0 < sscanf_ret); | ||
202 | 230 | ||
203 | 231 | ||
204 | if (0 == n_int) | 232 | if (0 == n_int) |
@@ -296,7 +324,7 @@ libgnunet_test_transport_plugin_cmd_udp_backchannel_init (void *cls) | |||
296 | 324 | ||
297 | GNUNET_log_setup ("udp-backchannel", | 325 | GNUNET_log_setup ("udp-backchannel", |
298 | "DEBUG", | 326 | "DEBUG", |
299 | NULL); | 327 | "plugin.out"); |
300 | 328 | ||
301 | api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions); | 329 | api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions); |
302 | api->start_testcase = &start_testcase; | 330 | api->start_testcase = &start_testcase; |
diff --git a/src/transport/transport_api_cmd_backchannel_check.c b/src/transport/transport_api_cmd_backchannel_check.c index b285d7abf..bf4fe2e20 100644 --- a/src/transport/transport_api_cmd_backchannel_check.c +++ b/src/transport/transport_api_cmd_backchannel_check.c | |||
@@ -36,7 +36,7 @@ | |||
36 | /** | 36 | /** |
37 | * Generic logging shortcut | 37 | * Generic logging shortcut |
38 | */ | 38 | */ |
39 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | 39 | #define LOG(kind, ...) GNUNET_log_from (kind, "udp-backchannel",__VA_ARGS__) |
40 | 40 | ||
41 | #define UDP "udp" | 41 | #define UDP "udp" |
42 | 42 | ||
@@ -413,6 +413,9 @@ backchannel_check_run (void *cls, | |||
413 | const struct GNUNET_TESTING_NetjailNode *node; | 413 | const struct GNUNET_TESTING_NetjailNode *node; |
414 | const struct GNUNET_TESTING_NetjailNamespace *namespace; | 414 | const struct GNUNET_TESTING_NetjailNamespace *namespace; |
415 | 415 | ||
416 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
417 | "check run 1\n"); | ||
418 | |||
416 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (is, | 419 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (is, |
417 | cs->start_peer_label); | 420 | cs->start_peer_label); |
418 | GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd, | 421 | GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd, |
@@ -429,7 +432,7 @@ backchannel_check_run (void *cls, | |||
429 | cs->topology); | 432 | cs->topology); |
430 | 433 | ||
431 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 434 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
432 | "check run\n"); | 435 | "check run 2\n"); |
433 | 436 | ||
434 | 437 | ||
435 | node_it = GNUNET_CONTAINER_multishortmap_iterator_create ( | 438 | node_it = GNUNET_CONTAINER_multishortmap_iterator_create ( |
@@ -450,6 +453,7 @@ backchannel_check_run (void *cls, | |||
450 | add_search_string (cs, node); | 453 | add_search_string (cs, node); |
451 | } | 454 | } |
452 | } | 455 | } |
456 | GNUNET_free (node_it); | ||
453 | namespace_it = GNUNET_CONTAINER_multishortmap_iterator_create ( | 457 | namespace_it = GNUNET_CONTAINER_multishortmap_iterator_create ( |
454 | cs->topology->map_namespaces); | 458 | cs->topology->map_namespaces); |
455 | while (GNUNET_YES == GNUNET_CONTAINER_multishortmap_iterator_next ( | 459 | while (GNUNET_YES == GNUNET_CONTAINER_multishortmap_iterator_next ( |
@@ -478,6 +482,7 @@ backchannel_check_run (void *cls, | |||
478 | add_search_string (cs, node); | 482 | add_search_string (cs, node); |
479 | } | 483 | } |
480 | } | 484 | } |
485 | GNUNET_free (node_it); | ||
481 | } | 486 | } |
482 | 487 | ||
483 | if (0 != cs->con_num) | 488 | if (0 != cs->con_num) |