aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-07-08 17:20:23 +0000
committerChristian Grothoff <christian@grothoff.org>2016-07-08 17:20:23 +0000
commitd8c53b12a818ff7cf82d06a1a69c395bdef85ee6 (patch)
tree0ebb0db416c157fcfde51a941185819dd12d51fd /src/testing
parent5184c17d32a39c928c2a0fec3ee1ad098bbaa562 (diff)
downloadgnunet-d8c53b12a818ff7cf82d06a1a69c395bdef85ee6.tar.gz
gnunet-d8c53b12a818ff7cf82d06a1a69c395bdef85ee6.zip
-avoid calling memcpy() with NULL argument, even if len is 0
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/list-keys.c5
-rw-r--r--src/testing/testing.c8
2 files changed, 7 insertions, 6 deletions
diff --git a/src/testing/list-keys.c b/src/testing/list-keys.c
index 1c469adcc..1fd46ebf2 100644
--- a/src/testing/list-keys.c
+++ b/src/testing/list-keys.c
@@ -72,7 +72,8 @@ run (void *cls, char *const *args, const char *cfgfile,
72 PRINTF ("Max keys %u reached\n", nmax); 72 PRINTF ("Max keys %u reached\n", nmax);
73 break; 73 break;
74 } 74 }
75 (void) memcpy (&pkey, data + (cnt * GNUNET_TESTING_HOSTKEYFILESIZE), 75 GNUNET_memcpy (&pkey,
76 data + (cnt * GNUNET_TESTING_HOSTKEYFILESIZE),
76 GNUNET_TESTING_HOSTKEYFILESIZE); 77 GNUNET_TESTING_HOSTKEYFILESIZE);
77 GNUNET_CRYPTO_eddsa_key_get_public (&pkey, &id.public_key); 78 GNUNET_CRYPTO_eddsa_key_get_public (&pkey, &id.public_key);
78 PRINTF ("Key %u: %s\n", cnt, GNUNET_i2s_full (&id)); 79 PRINTF ("Key %u: %s\n", cnt, GNUNET_i2s_full (&id));
@@ -98,7 +99,7 @@ int main (int argc, char *argv[])
98 99
99 result = GNUNET_SYSERR; 100 result = GNUNET_SYSERR;
100 nkeys = 10; 101 nkeys = 10;
101 ret = 102 ret =
102 GNUNET_PROGRAM_run (argc, argv, "list-keys", "Lists the peer IDs corresponding to the given keys file\n", 103 GNUNET_PROGRAM_run (argc, argv, "list-keys", "Lists the peer IDs corresponding to the given keys file\n",
103 option, &run, NULL); 104 option, &run, NULL);
104 if (GNUNET_OK != ret) 105 if (GNUNET_OK != ret)
diff --git a/src/testing/testing.c b/src/testing/testing.c
index 13ebabd1d..98ac76fb7 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -722,7 +722,7 @@ GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system,
722 return NULL; 722 return NULL;
723 } 723 }
724 private_key = GNUNET_new (struct GNUNET_CRYPTO_EddsaPrivateKey); 724 private_key = GNUNET_new (struct GNUNET_CRYPTO_EddsaPrivateKey);
725 memcpy (private_key, 725 GNUNET_memcpy (private_key,
726 system->hostkeys_data + 726 system->hostkeys_data +
727 (key_number * GNUNET_TESTING_HOSTKEYFILESIZE), 727 (key_number * GNUNET_TESTING_HOSTKEYFILESIZE),
728 GNUNET_TESTING_HOSTKEYFILESIZE); 728 GNUNET_TESTING_HOSTKEYFILESIZE);
@@ -1296,14 +1296,14 @@ GNUNET_TESTING_peer_get_identity (struct GNUNET_TESTING_Peer *peer,
1296{ 1296{
1297 if (NULL != peer->id) 1297 if (NULL != peer->id)
1298 { 1298 {
1299 memcpy (id, peer->id, sizeof (struct GNUNET_PeerIdentity)); 1299 GNUNET_memcpy (id, peer->id, sizeof (struct GNUNET_PeerIdentity));
1300 return; 1300 return;
1301 } 1301 }
1302 peer->id = GNUNET_new (struct GNUNET_PeerIdentity); 1302 peer->id = GNUNET_new (struct GNUNET_PeerIdentity);
1303 GNUNET_free (GNUNET_TESTING_hostkey_get (peer->system, 1303 GNUNET_free (GNUNET_TESTING_hostkey_get (peer->system,
1304 peer->key_number, 1304 peer->key_number,
1305 peer->id)); 1305 peer->id));
1306 memcpy (id, peer->id, sizeof (struct GNUNET_PeerIdentity)); 1306 GNUNET_memcpy (id, peer->id, sizeof (struct GNUNET_PeerIdentity));
1307} 1307}
1308 1308
1309 1309
@@ -1724,7 +1724,7 @@ GNUNET_TESTING_get_testname_from_underscore (const char *argv0)
1724 char *ret; 1724 char *ret;
1725 char *dot; 1725 char *dot;
1726 1726
1727 memcpy (sbuf, argv0, slen); 1727 GNUNET_memcpy (sbuf, argv0, slen);
1728 ret = strrchr (sbuf, '_'); 1728 ret = strrchr (sbuf, '_');
1729 if (NULL == ret) 1729 if (NULL == ret)
1730 return NULL; 1730 return NULL;