diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-10-18 11:39:51 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-10-18 11:39:51 +0000 |
commit | 2b0d80841a3d9a743f1213a530221dc125fab051 (patch) | |
tree | 3f6630e9a0a7639bb8497fd94e98340e88a24d2a /src | |
parent | 5dcfccf5803510e9f4d2339b19dc617b4043153a (diff) | |
download | gnunet-2b0d80841a3d9a743f1213a530221dc125fab051.tar.gz gnunet-2b0d80841a3d9a743f1213a530221dc125fab051.zip |
-remove expired records immediately after decryption
Diffstat (limited to 'src')
-rw-r--r-- | src/gnsrecord/gnsrecord_crypto.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/gnsrecord/gnsrecord_crypto.c b/src/gnsrecord/gnsrecord_crypto.c index 99a97dcdd..0d173c26e 100644 --- a/src/gnsrecord/gnsrecord_crypto.c +++ b/src/gnsrecord/gnsrecord_crypto.c | |||
@@ -204,6 +204,9 @@ GNUNET_GNSRECORD_block_decrypt (const struct GNUNET_GNSRECORD_Block *block, | |||
204 | } | 204 | } |
205 | { | 205 | { |
206 | struct GNUNET_GNSRECORD_Data rd[rd_count]; | 206 | struct GNUNET_GNSRECORD_Data rd[rd_count]; |
207 | unsigned int i; | ||
208 | unsigned int j; | ||
209 | struct GNUNET_TIME_Absolute now; | ||
207 | 210 | ||
208 | if (GNUNET_OK != | 211 | if (GNUNET_OK != |
209 | GNUNET_GNSRECORD_records_deserialize (payload_len - sizeof (uint32_t), | 212 | GNUNET_GNSRECORD_records_deserialize (payload_len - sizeof (uint32_t), |
@@ -214,6 +217,25 @@ GNUNET_GNSRECORD_block_decrypt (const struct GNUNET_GNSRECORD_Block *block, | |||
214 | GNUNET_break_op (0); | 217 | GNUNET_break_op (0); |
215 | return GNUNET_SYSERR; | 218 | return GNUNET_SYSERR; |
216 | } | 219 | } |
220 | /* hide expired records */ | ||
221 | now = GNUNET_TIME_absolute_get (); | ||
222 | j = 0; | ||
223 | for (i=0;i<rd_count;i++) | ||
224 | { | ||
225 | if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) | ||
226 | { | ||
227 | /* encrypted blocks must never have relative expiration times, skip! */ | ||
228 | GNUNET_break_op (0); | ||
229 | continue; | ||
230 | } | ||
231 | if (rd[i].expiration_time >= now.abs_value_us) | ||
232 | { | ||
233 | if (j != i) | ||
234 | rd[j] = rd[i]; | ||
235 | j++; | ||
236 | } | ||
237 | } | ||
238 | rd_count = j; | ||
217 | if (NULL != proc) | 239 | if (NULL != proc) |
218 | proc (proc_cls, rd_count, (0 != rd_count) ? rd : NULL); | 240 | proc (proc_cls, rd_count, (0 != rd_count) ? rd : NULL); |
219 | } | 241 | } |