diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-01-06 21:05:03 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-01-06 21:05:03 +0100 |
commit | 8dea30580ceaa571c9d85b5e8a563201ed622ed7 (patch) | |
tree | 97cabce64f3d7c87672fad8d3ab8783ac2760187 /src/fs | |
parent | 3a18658cf9196ecd8e55d5231818e6ee3b242a43 (diff) | |
download | gnunet-8dea30580ceaa571c9d85b5e8a563201ed622ed7.tar.gz gnunet-8dea30580ceaa571c9d85b5e8a563201ed622ed7.zip |
fix potential use of uninitialized key
Diffstat (limited to 'src/fs')
-rw-r--r-- | src/fs/fs_search.c | 19 | ||||
-rw-r--r-- | src/fs/fs_uri.c | 25 |
2 files changed, 34 insertions, 10 deletions
diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c index 8c6f5edcf..83aae2fc5 100644 --- a/src/fs/fs_search.c +++ b/src/fs/fs_search.c | |||
@@ -568,7 +568,13 @@ process_ksk_result (struct GNUNET_FS_SearchContext *sc, | |||
568 | 568 | ||
569 | /* check if new */ | 569 | /* check if new */ |
570 | GNUNET_assert (NULL != sc); | 570 | GNUNET_assert (NULL != sc); |
571 | GNUNET_FS_uri_to_key (uri, &key); | 571 | if (GNUNET_OK != |
572 | GNUNET_FS_uri_to_key (uri, | ||
573 | &key)) | ||
574 | { | ||
575 | GNUNET_break_op (0); | ||
576 | return; | ||
577 | } | ||
572 | if (GNUNET_SYSERR == | 578 | if (GNUNET_SYSERR == |
573 | GNUNET_CONTAINER_multihashmap_get_multiple (ent->results, | 579 | GNUNET_CONTAINER_multihashmap_get_multiple (ent->results, |
574 | &key, | 580 | &key, |
@@ -680,8 +686,15 @@ process_sks_result (struct GNUNET_FS_SearchContext *sc, | |||
680 | 686 | ||
681 | /* check if new */ | 687 | /* check if new */ |
682 | GNUNET_assert (NULL != sc); | 688 | GNUNET_assert (NULL != sc); |
683 | GNUNET_FS_uri_to_key (uri, &key); | 689 | if (GNUNET_OK != |
684 | GNUNET_CRYPTO_hash_xor (&uri->data.chk.chk.key, &uri->data.chk.chk.query, | 690 | GNUNET_FS_uri_to_key (uri, |
691 | &key)) | ||
692 | { | ||
693 | GNUNET_break (0); | ||
694 | return; | ||
695 | } | ||
696 | GNUNET_CRYPTO_hash_xor (&uri->data.chk.chk.key, | ||
697 | &uri->data.chk.chk.query, | ||
685 | &key); | 698 | &key); |
686 | if (GNUNET_SYSERR == | 699 | if (GNUNET_SYSERR == |
687 | GNUNET_CONTAINER_multihashmap_get_multiple (sc->master_result_map, &key, | 700 | GNUNET_CONTAINER_multihashmap_get_multiple (sc->master_result_map, &key, |
diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c index 11968b750..b90c75981 100644 --- a/src/fs/fs_uri.c +++ b/src/fs/fs_uri.c | |||
@@ -96,8 +96,9 @@ | |||
96 | * | 96 | * |
97 | * @param uri uri to convert to a unique key | 97 | * @param uri uri to convert to a unique key |
98 | * @param key where to store the unique key | 98 | * @param key where to store the unique key |
99 | * @return #GNUNET_OK on success | ||
99 | */ | 100 | */ |
100 | void | 101 | int |
101 | GNUNET_FS_uri_to_key (const struct GNUNET_FS_Uri *uri, | 102 | GNUNET_FS_uri_to_key (const struct GNUNET_FS_Uri *uri, |
102 | struct GNUNET_HashCode *key) | 103 | struct GNUNET_HashCode *key) |
103 | { | 104 | { |
@@ -105,25 +106,35 @@ GNUNET_FS_uri_to_key (const struct GNUNET_FS_Uri *uri, | |||
105 | { | 106 | { |
106 | case GNUNET_FS_URI_CHK: | 107 | case GNUNET_FS_URI_CHK: |
107 | *key = uri->data.chk.chk.query; | 108 | *key = uri->data.chk.chk.query; |
108 | return; | 109 | return GNUNET_OK; |
109 | case GNUNET_FS_URI_SKS: | 110 | case GNUNET_FS_URI_SKS: |
110 | GNUNET_CRYPTO_hash (uri->data.sks.identifier, | 111 | GNUNET_CRYPTO_hash (uri->data.sks.identifier, |
111 | strlen (uri->data.sks.identifier), key); | 112 | strlen (uri->data.sks.identifier), |
112 | break; | 113 | key); |
114 | return GNUNET_OK; | ||
113 | case GNUNET_FS_URI_KSK: | 115 | case GNUNET_FS_URI_KSK: |
114 | if (uri->data.ksk.keywordCount > 0) | 116 | if (uri->data.ksk.keywordCount > 0) |
117 | { | ||
115 | GNUNET_CRYPTO_hash (uri->data.ksk.keywords[0], | 118 | GNUNET_CRYPTO_hash (uri->data.ksk.keywords[0], |
116 | strlen (uri->data.ksk.keywords[0]), key); | 119 | strlen (uri->data.ksk.keywords[0]), |
120 | key); | ||
121 | return GNUNET_OK; | ||
122 | } | ||
123 | else | ||
124 | { | ||
125 | memset (key, 0, sizeof (struct GNUNET_HashCode)); | ||
126 | return GNUNET_SYSERR; | ||
127 | } | ||
117 | break; | 128 | break; |
118 | case GNUNET_FS_URI_LOC: | 129 | case GNUNET_FS_URI_LOC: |
119 | GNUNET_CRYPTO_hash (&uri->data.loc.fi, | 130 | GNUNET_CRYPTO_hash (&uri->data.loc.fi, |
120 | sizeof (struct FileIdentifier) + | 131 | sizeof (struct FileIdentifier) + |
121 | sizeof (struct GNUNET_PeerIdentity), | 132 | sizeof (struct GNUNET_PeerIdentity), |
122 | key); | 133 | key); |
123 | break; | 134 | return GNUNET_OK; |
124 | default: | 135 | default: |
125 | memset (key, 0, sizeof (struct GNUNET_HashCode)); | 136 | memset (key, 0, sizeof (struct GNUNET_HashCode)); |
126 | break; | 137 | return GNUNET_SYSERR; |
127 | } | 138 | } |
128 | } | 139 | } |
129 | 140 | ||