diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-07-08 17:20:23 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-07-08 17:20:23 +0000 |
commit | d8c53b12a818ff7cf82d06a1a69c395bdef85ee6 (patch) | |
tree | 0ebb0db416c157fcfde51a941185819dd12d51fd /src/fs/fs_uri.c | |
parent | 5184c17d32a39c928c2a0fec3ee1ad098bbaa562 (diff) | |
download | gnunet-d8c53b12a818ff7cf82d06a1a69c395bdef85ee6.tar.gz gnunet-d8c53b12a818ff7cf82d06a1a69c395bdef85ee6.zip |
-avoid calling memcpy() with NULL argument, even if len is 0
Diffstat (limited to 'src/fs/fs_uri.c')
-rw-r--r-- | src/fs/fs_uri.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c index 12cae6b64..fa27e6e9b 100644 --- a/src/fs/fs_uri.c +++ b/src/fs/fs_uri.c | |||
@@ -417,9 +417,9 @@ uri_chk_parse (const char *s, | |||
417 | *emsg = GNUNET_strdup (_("Malformed CHK URI (wrong syntax)")); | 417 | *emsg = GNUNET_strdup (_("Malformed CHK URI (wrong syntax)")); |
418 | return NULL; | 418 | return NULL; |
419 | } | 419 | } |
420 | memcpy (h1, &s[pos], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); | 420 | GNUNET_memcpy (h1, &s[pos], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); |
421 | h1[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] = '\0'; | 421 | h1[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] = '\0'; |
422 | memcpy (h2, &s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)], | 422 | GNUNET_memcpy (h2, &s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)], |
423 | sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); | 423 | sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); |
424 | h2[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] = '\0'; | 424 | h2[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] = '\0'; |
425 | 425 | ||
@@ -511,9 +511,9 @@ uri_loc_parse (const char *s, | |||
511 | *emsg = GNUNET_strdup (_("LOC URI malformed (wrong syntax)")); | 511 | *emsg = GNUNET_strdup (_("LOC URI malformed (wrong syntax)")); |
512 | return NULL; | 512 | return NULL; |
513 | } | 513 | } |
514 | memcpy (h1, &s[pos], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); | 514 | GNUNET_memcpy (h1, &s[pos], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); |
515 | h1[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] = '\0'; | 515 | h1[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] = '\0'; |
516 | memcpy (h2, &s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)], | 516 | GNUNET_memcpy (h2, &s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)], |
517 | sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); | 517 | sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); |
518 | h2[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] = '\0'; | 518 | h2[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] = '\0'; |
519 | 519 | ||
@@ -978,7 +978,7 @@ GNUNET_FS_uri_dup (const struct GNUNET_FS_Uri *uri) | |||
978 | if (uri == NULL) | 978 | if (uri == NULL) |
979 | return NULL; | 979 | return NULL; |
980 | ret = GNUNET_new (struct GNUNET_FS_Uri); | 980 | ret = GNUNET_new (struct GNUNET_FS_Uri); |
981 | memcpy (ret, uri, sizeof (struct GNUNET_FS_Uri)); | 981 | GNUNET_memcpy (ret, uri, sizeof (struct GNUNET_FS_Uri)); |
982 | switch (ret->type) | 982 | switch (ret->type) |
983 | { | 983 | { |
984 | case GNUNET_FS_URI_KSK: | 984 | case GNUNET_FS_URI_KSK: |
@@ -1450,7 +1450,7 @@ normalize_metadata (enum EXTRACTOR_MetaFormat format, | |||
1450 | { | 1450 | { |
1451 | /* u8_tolower allocates a non-NULL-terminated string! */ | 1451 | /* u8_tolower allocates a non-NULL-terminated string! */ |
1452 | free_str = GNUNET_malloc (r_len + 1); | 1452 | free_str = GNUNET_malloc (r_len + 1); |
1453 | memcpy (free_str, normalized, r_len); | 1453 | GNUNET_memcpy (free_str, normalized, r_len); |
1454 | free_str[r_len] = '\0'; | 1454 | free_str[r_len] = '\0'; |
1455 | free (normalized); | 1455 | free (normalized); |
1456 | normalized = free_str; | 1456 | normalized = free_str; |