aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-05-13 21:17:12 +0200
committerChristian Grothoff <christian@grothoff.org>2018-05-13 21:17:12 +0200
commit98ac2b34f979cf10da24c984e690dabf7b34794b (patch)
treeed4fd15409066b5403f02c23aab9e14b179bc874 /src
parentfa2978883e1585b1eeff3a22b7a9b4f174a45ca3 (diff)
downloadgnunet-98ac2b34f979cf10da24c984e690dabf7b34794b.tar.gz
gnunet-98ac2b34f979cf10da24c984e690dabf7b34794b.zip
add some extra GNS-record well-formedness checks if logging is enabled
Diffstat (limited to 'src')
-rw-r--r--src/dns/dnsparser.c8
-rw-r--r--src/gns/gns_api.c4
-rw-r--r--src/gnsrecord/gnsrecord.c12
-rw-r--r--src/gnsrecord/gnsrecord_crypto.c29
-rw-r--r--src/gnsrecord/gnsrecord_serialization.c42
-rw-r--r--src/namestore/gnunet-service-namestore.c22
-rw-r--r--src/zonemaster/gnunet-service-zonemaster-monitor.c18
-rw-r--r--src/zonemaster/gnunet-service-zonemaster.c30
8 files changed, 104 insertions, 61 deletions
diff --git a/src/dns/dnsparser.c b/src/dns/dnsparser.c
index 7e200ee7c..6f9a24b7e 100644
--- a/src/dns/dnsparser.c
+++ b/src/dns/dnsparser.c
@@ -815,7 +815,9 @@ GNUNET_DNSPARSER_builder_add_name (char *dst,
815 return GNUNET_SYSERR; 815 return GNUNET_SYSERR;
816 816
817 if (IDNA_SUCCESS != 817 if (IDNA_SUCCESS !=
818 (rc = idna_to_ascii_8z (name, &idna_start, IDNA_ALLOW_UNASSIGNED))) 818 (rc = idna_to_ascii_8z (name,
819 &idna_start,
820 IDNA_ALLOW_UNASSIGNED)))
819 { 821 {
820 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 822 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
821 _("Failed to convert UTF-8 name `%s' to DNS IDNA format: %s\n"), 823 _("Failed to convert UTF-8 name `%s' to DNS IDNA format: %s\n"),
@@ -841,7 +843,9 @@ GNUNET_DNSPARSER_builder_add_name (char *dst,
841 goto fail; /* segment too long or empty */ 843 goto fail; /* segment too long or empty */
842 } 844 }
843 dst[pos++] = (char) (uint8_t) len; 845 dst[pos++] = (char) (uint8_t) len;
844 GNUNET_memcpy (&dst[pos], idna_name, len); 846 GNUNET_memcpy (&dst[pos],
847 idna_name,
848 len);
845 pos += len; 849 pos += len;
846 idna_name += len + 1; /* also skip dot */ 850 idna_name += len + 1; /* also skip dot */
847 } 851 }
diff --git a/src/gns/gns_api.c b/src/gns/gns_api.c
index ff67f0205..ed30fa44c 100644
--- a/src/gns/gns_api.c
+++ b/src/gns/gns_api.c
@@ -157,7 +157,7 @@ check_result (void *cls,
157 size_t mlen = ntohs (lookup_msg->header.size) - sizeof (*lookup_msg); 157 size_t mlen = ntohs (lookup_msg->header.size) - sizeof (*lookup_msg);
158 uint32_t rd_count = ntohl (lookup_msg->rd_count); 158 uint32_t rd_count = ntohl (lookup_msg->rd_count);
159 struct GNUNET_GNSRECORD_Data rd[rd_count]; 159 struct GNUNET_GNSRECORD_Data rd[rd_count];
160 160
161 (void) cls; 161 (void) cls;
162 if (GNUNET_SYSERR == 162 if (GNUNET_SYSERR ==
163 GNUNET_GNSRECORD_records_deserialize (mlen, 163 GNUNET_GNSRECORD_records_deserialize (mlen,
@@ -201,7 +201,7 @@ handle_result (void *cls,
201 return; 201 return;
202 proc = lr->lookup_proc; 202 proc = lr->lookup_proc;
203 proc_cls = lr->proc_cls; 203 proc_cls = lr->proc_cls;
204 204
205 GNUNET_assert (GNUNET_OK == 205 GNUNET_assert (GNUNET_OK ==
206 GNUNET_GNSRECORD_records_deserialize (mlen, 206 GNUNET_GNSRECORD_records_deserialize (mlen,
207 (const char*) &lookup_msg[1], 207 (const char*) &lookup_msg[1],
diff --git a/src/gnsrecord/gnsrecord.c b/src/gnsrecord/gnsrecord.c
index 8fc039fc6..ece1665fc 100644
--- a/src/gnsrecord/gnsrecord.c
+++ b/src/gnsrecord/gnsrecord.c
@@ -114,10 +114,9 @@ init ()
114void __attribute__ ((destructor)) 114void __attribute__ ((destructor))
115GNSRECORD_fini () 115GNSRECORD_fini ()
116{ 116{
117 unsigned int i;
118 struct Plugin *plugin; 117 struct Plugin *plugin;
119 118
120 for (i = 0; i < num_plugins; i++) 119 for (unsigned int i = 0; i < num_plugins; i++)
121 { 120 {
122 plugin = gns_plugins[i]; 121 plugin = gns_plugins[i];
123 GNUNET_break (NULL == 122 GNUNET_break (NULL ==
@@ -146,12 +145,11 @@ GNUNET_GNSRECORD_value_to_string (uint32_t type,
146 const void *data, 145 const void *data,
147 size_t data_size) 146 size_t data_size)
148{ 147{
149 unsigned int i;
150 struct Plugin *plugin; 148 struct Plugin *plugin;
151 char *ret; 149 char *ret;
152 150
153 init (); 151 init ();
154 for (i = 0; i < num_plugins; i++) 152 for (unsigned int i = 0; i < num_plugins; i++)
155 { 153 {
156 plugin = gns_plugins[i]; 154 plugin = gns_plugins[i];
157 if (NULL != (ret = plugin->api->value_to_string (plugin->api->cls, 155 if (NULL != (ret = plugin->api->value_to_string (plugin->api->cls,
@@ -180,11 +178,10 @@ GNUNET_GNSRECORD_string_to_value (uint32_t type,
180 void **data, 178 void **data,
181 size_t *data_size) 179 size_t *data_size)
182{ 180{
183 unsigned int i;
184 struct Plugin *plugin; 181 struct Plugin *plugin;
185 182
186 init (); 183 init ();
187 for (i = 0; i < num_plugins; i++) 184 for (unsigned int i = 0; i < num_plugins; i++)
188 { 185 {
189 plugin = gns_plugins[i]; 186 plugin = gns_plugins[i];
190 if (GNUNET_OK == plugin->api->string_to_value (plugin->api->cls, 187 if (GNUNET_OK == plugin->api->string_to_value (plugin->api->cls,
@@ -234,14 +231,13 @@ GNUNET_GNSRECORD_typename_to_number (const char *dns_typename)
234const char * 231const char *
235GNUNET_GNSRECORD_number_to_typename (uint32_t type) 232GNUNET_GNSRECORD_number_to_typename (uint32_t type)
236{ 233{
237 unsigned int i;
238 struct Plugin *plugin; 234 struct Plugin *plugin;
239 const char * ret; 235 const char * ret;
240 236
241 if (GNUNET_GNSRECORD_TYPE_ANY == type) 237 if (GNUNET_GNSRECORD_TYPE_ANY == type)
242 return "ANY"; 238 return "ANY";
243 init (); 239 init ();
244 for (i = 0; i < num_plugins; i++) 240 for (unsigned int i = 0; i < num_plugins; i++)
245 { 241 {
246 plugin = gns_plugins[i]; 242 plugin = gns_plugins[i];
247 if (NULL != (ret = plugin->api->number_to_typename (plugin->api->cls, 243 if (NULL != (ret = plugin->api->number_to_typename (plugin->api->cls,
diff --git a/src/gnsrecord/gnsrecord_crypto.c b/src/gnsrecord/gnsrecord_crypto.c
index cebc842f3..6d59a545a 100644
--- a/src/gnsrecord/gnsrecord_crypto.c
+++ b/src/gnsrecord/gnsrecord_crypto.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2009-2013 GNUnet e.V. 3 Copyright (C) 2009-2013, 2018 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -94,7 +94,7 @@ block_create (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
94 struct GNUNET_CRYPTO_EcdsaPrivateKey *dkey; 94 struct GNUNET_CRYPTO_EcdsaPrivateKey *dkey;
95 struct GNUNET_CRYPTO_SymmetricInitializationVector iv; 95 struct GNUNET_CRYPTO_SymmetricInitializationVector iv;
96 struct GNUNET_CRYPTO_SymmetricSessionKey skey; 96 struct GNUNET_CRYPTO_SymmetricSessionKey skey;
97 struct GNUNET_GNSRECORD_Data rdc[rd_count]; 97 struct GNUNET_GNSRECORD_Data rdc[GNUNET_NZL(rd_count)];
98 uint32_t rd_count_nbo; 98 uint32_t rd_count_nbo;
99 struct GNUNET_TIME_Absolute now; 99 struct GNUNET_TIME_Absolute now;
100 100
@@ -246,6 +246,7 @@ GNUNET_GNSRECORD_block_create2 (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
246 GNUNET_CRYPTO_ecdsa_key_get_public (key, 246 GNUNET_CRYPTO_ecdsa_key_get_public (key,
247 &line->pkey); 247 &line->pkey);
248 } 248 }
249#undef CSIZE
249 return block_create (key, 250 return block_create (key,
250 &line->pkey, 251 &line->pkey,
251 expire, 252 expire,
@@ -304,18 +305,21 @@ GNUNET_GNSRECORD_block_decrypt (const struct GNUNET_GNSRECORD_Block *block,
304 GNUNET_break_op (0); 305 GNUNET_break_op (0);
305 return GNUNET_SYSERR; 306 return GNUNET_SYSERR;
306 } 307 }
307 derive_block_aes_key (&iv, &skey, label, zone_key); 308 derive_block_aes_key (&iv,
309 &skey,
310 label,
311 zone_key);
308 { 312 {
309 char payload[payload_len]; 313 char payload[payload_len];
310 uint32_t rd_count; 314 uint32_t rd_count;
311 315
312 GNUNET_break (payload_len == 316 GNUNET_break (payload_len ==
313 GNUNET_CRYPTO_symmetric_decrypt (&block[1], payload_len, 317 GNUNET_CRYPTO_symmetric_decrypt (&block[1], payload_len,
314 &skey, &iv, 318 &skey, &iv,
315 payload)); 319 payload));
316 GNUNET_memcpy (&rd_count, 320 GNUNET_memcpy (&rd_count,
317 payload, 321 payload,
318 sizeof (uint32_t)); 322 sizeof (uint32_t));
319 rd_count = ntohl (rd_count); 323 rd_count = ntohl (rd_count);
320 if (rd_count > 2048) 324 if (rd_count > 2048)
321 { 325 {
@@ -324,7 +328,7 @@ GNUNET_GNSRECORD_block_decrypt (const struct GNUNET_GNSRECORD_Block *block,
324 return GNUNET_SYSERR; 328 return GNUNET_SYSERR;
325 } 329 }
326 { 330 {
327 struct GNUNET_GNSRECORD_Data rd[rd_count]; 331 struct GNUNET_GNSRECORD_Data rd[GNUNET_NZL(rd_count)];
328 unsigned int j; 332 unsigned int j;
329 struct GNUNET_TIME_Absolute now; 333 struct GNUNET_TIME_Absolute now;
330 334
@@ -359,10 +363,13 @@ GNUNET_GNSRECORD_block_decrypt (const struct GNUNET_GNSRECORD_Block *block,
359 continue; 363 continue;
360 if (rd[i].expiration_time < now.abs_value_us) 364 if (rd[i].expiration_time < now.abs_value_us)
361 include_record = GNUNET_NO; /* Shadow record is expired */ 365 include_record = GNUNET_NO; /* Shadow record is expired */
362 if ((rd[k].record_type == rd[i].record_type) 366 if ( (rd[k].record_type == rd[i].record_type) &&
363 && (rd[k].expiration_time >= now.abs_value_us) 367 (rd[k].expiration_time >= now.abs_value_us) &&
364 && (0 == (rd[k].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD))) 368 (0 == (rd[k].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD)) )
369 {
365 include_record = GNUNET_NO; /* We have a non-expired, non-shadow record of the same type */ 370 include_record = GNUNET_NO; /* We have a non-expired, non-shadow record of the same type */
371 break;
372 }
366 } 373 }
367 if (GNUNET_YES == include_record) 374 if (GNUNET_YES == include_record)
368 { 375 {
diff --git a/src/gnsrecord/gnsrecord_serialization.c b/src/gnsrecord/gnsrecord_serialization.c
index 56521945d..1db27464f 100644
--- a/src/gnsrecord/gnsrecord_serialization.c
+++ b/src/gnsrecord/gnsrecord_serialization.c
@@ -127,17 +127,38 @@ GNUNET_GNSRECORD_records_serialize (unsigned int rd_count,
127 rec.record_type = htonl (rd[i].record_type); 127 rec.record_type = htonl (rd[i].record_type);
128 rec.flags = htonl (rd[i].flags); 128 rec.flags = htonl (rd[i].flags);
129 if (off + sizeof (rec) > dest_size) 129 if (off + sizeof (rec) > dest_size)
130 {
131 GNUNET_break (0);
130 return -1; 132 return -1;
133 }
131 GNUNET_memcpy (&dest[off], 134 GNUNET_memcpy (&dest[off],
132 &rec, 135 &rec,
133 sizeof (rec)); 136 sizeof (rec));
134 off += sizeof (rec); 137 off += sizeof (rec);
135 if (off + rd[i].data_size > dest_size) 138 if (off + rd[i].data_size > dest_size)
139 {
140 GNUNET_break (0);
136 return -1; 141 return -1;
142 }
137 GNUNET_memcpy (&dest[off], 143 GNUNET_memcpy (&dest[off],
138 rd[i].data, 144 rd[i].data,
139 rd[i].data_size); 145 rd[i].data_size);
140 off += rd[i].data_size; 146 off += rd[i].data_size;
147#if GNUNET_EXTRA_LOGGING
148 {
149 char *str;
150
151 str = GNUNET_GNSRECORD_value_to_string (rd[i].record_type,
152 rd[i].data,
153 rd[i].data_size);
154 if (NULL == str)
155 {
156 GNUNET_break_op (0);
157 return GNUNET_SYSERR;
158 }
159 GNUNET_free (str);
160 }
161#endif
141 } 162 }
142 return off; 163 return off;
143} 164}
@@ -165,7 +186,10 @@ GNUNET_GNSRECORD_records_deserialize (size_t len,
165 for (unsigned int i=0;i<rd_count;i++) 186 for (unsigned int i=0;i<rd_count;i++)
166 { 187 {
167 if (off + sizeof (rec) > len) 188 if (off + sizeof (rec) > len)
189 {
190 GNUNET_break_op (0);
168 return GNUNET_SYSERR; 191 return GNUNET_SYSERR;
192 }
169 GNUNET_memcpy (&rec, 193 GNUNET_memcpy (&rec,
170 &src[off], 194 &src[off],
171 sizeof (rec)); 195 sizeof (rec));
@@ -175,9 +199,27 @@ GNUNET_GNSRECORD_records_deserialize (size_t len,
175 dest[i].flags = ntohl (rec.flags); 199 dest[i].flags = ntohl (rec.flags);
176 off += sizeof (rec); 200 off += sizeof (rec);
177 if (off + dest[i].data_size > len) 201 if (off + dest[i].data_size > len)
202 {
203 GNUNET_break_op (0);
178 return GNUNET_SYSERR; 204 return GNUNET_SYSERR;
205 }
179 dest[i].data = &src[off]; 206 dest[i].data = &src[off];
180 off += dest[i].data_size; 207 off += dest[i].data_size;
208#if GNUNET_EXTRA_LOGGING
209 {
210 char *str;
211
212 str = GNUNET_GNSRECORD_value_to_string (dest[i].record_type,
213 dest[i].data,
214 dest[i].data_size);
215 if (NULL == str)
216 {
217 GNUNET_break_op (0);
218 return GNUNET_SYSERR;
219 }
220 GNUNET_free (str);
221 }
222#endif
181 LOG (GNUNET_ERROR_TYPE_DEBUG, 223 LOG (GNUNET_ERROR_TYPE_DEBUG,
182 "Deserialized record %u with flags %d and expiration time %llu\n", 224 "Deserialized record %u with flags %d and expiration time %llu\n",
183 i, 225 i,
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c
index 5e654dbde..8e88558de 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -550,18 +550,16 @@ merge_with_nick_records (const struct GNUNET_GNSRECORD_Data *nick_rd,
550 uint64_t latest_expiration; 550 uint64_t latest_expiration;
551 size_t req; 551 size_t req;
552 char *data; 552 char *data;
553 int record_offset;
554 size_t data_offset; 553 size_t data_offset;
555 554
556 (*rdc_res) = 1 + rd2_length; 555 (*rdc_res) = 1 + rd2_length;
557 if (0 == 1 + rd2_length) 556 if (0 == 1 + rd2_length)
558 { 557 {
558 GNUNET_break (0);
559 (*rd_res) = NULL; 559 (*rd_res) = NULL;
560 return; 560 return;
561 } 561 }
562 req = 0; 562 req = sizeof (struct GNUNET_GNSRECORD_Data) + nick_rd->data_size;
563 for (unsigned int c=0; c< 1; c++)
564 req += sizeof (struct GNUNET_GNSRECORD_Data) + nick_rd[c].data_size;
565 for (unsigned int c=0; c< rd2_length; c++) 563 for (unsigned int c=0; c< rd2_length; c++)
566 req += sizeof (struct GNUNET_GNSRECORD_Data) + rd2[c].data_size; 564 req += sizeof (struct GNUNET_GNSRECORD_Data) + rd2[c].data_size;
567 (*rd_res) = GNUNET_malloc (req); 565 (*rd_res) = GNUNET_malloc (req);
@@ -580,20 +578,19 @@ merge_with_nick_records (const struct GNUNET_GNSRECORD_Data *nick_rd,
580 latest_expiration = rd2[c].expiration_time; 578 latest_expiration = rd2[c].expiration_time;
581 (*rd_res)[c] = rd2[c]; 579 (*rd_res)[c] = rd2[c];
582 (*rd_res)[c].data = (void *) &data[data_offset]; 580 (*rd_res)[c].data = (void *) &data[data_offset];
583 GNUNET_memcpy ((void *) (*rd_res)[c].data, 581 GNUNET_memcpy (&data[data_offset],
584 rd2[c].data, 582 rd2[c].data,
585 rd2[c].data_size); 583 rd2[c].data_size);
586 data_offset += (*rd_res)[c].data_size; 584 data_offset += (*rd_res)[c].data_size;
587 } 585 }
588 /* append nick */ 586 /* append nick */
589 record_offset = rd2_length; 587 (*rd_res)[rd2_length] = *nick_rd;
590 (*rd_res)[record_offset] = *nick_rd; 588 (*rd_res)[rd2_length].expiration_time = latest_expiration;
591 (*rd_res)[record_offset].expiration_time = latest_expiration; 589 (*rd_res)[rd2_length].data = (void *) &data[data_offset];
592 (*rd_res)[record_offset].data = (void *) &data[data_offset]; 590 GNUNET_memcpy ((void *) (*rd_res)[rd2_length].data,
593 GNUNET_memcpy ((void *) (*rd_res)[record_offset].data,
594 nick_rd->data, 591 nick_rd->data,
595 nick_rd->data_size); 592 nick_rd->data_size);
596 data_offset += (*rd_res)[record_offset].data_size; 593 data_offset += (*rd_res)[rd2_length].data_size;
597 GNUNET_assert (req == (sizeof (struct GNUNET_GNSRECORD_Data)) * (*rdc_res) + data_offset); 594 GNUNET_assert (req == (sizeof (struct GNUNET_GNSRECORD_Data)) * (*rdc_res) + data_offset);
598} 595}
599 596
@@ -647,7 +644,8 @@ send_lookup_response (struct NamestoreClient *nc,
647 } 644 }
648 645
649 name_len = strlen (name) + 1; 646 name_len = strlen (name) + 1;
650 rd_ser_len = GNUNET_GNSRECORD_records_get_size (res_count, res); 647 rd_ser_len = GNUNET_GNSRECORD_records_get_size (res_count,
648 res);
651 env = GNUNET_MQ_msg_extra (zir_msg, 649 env = GNUNET_MQ_msg_extra (zir_msg,
652 name_len + rd_ser_len, 650 name_len + rd_ser_len,
653 GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT); 651 GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT);
diff --git a/src/zonemaster/gnunet-service-zonemaster-monitor.c b/src/zonemaster/gnunet-service-zonemaster-monitor.c
index 46feb117f..f7ae55ba7 100644
--- a/src/zonemaster/gnunet-service-zonemaster-monitor.c
+++ b/src/zonemaster/gnunet-service-zonemaster-monitor.c
@@ -214,16 +214,14 @@ convert_records_for_export (const struct GNUNET_GNSRECORD_Data *rd,
214 rd_public_count = 0; 214 rd_public_count = 0;
215 now = GNUNET_TIME_absolute_get (); 215 now = GNUNET_TIME_absolute_get ();
216 for (unsigned int i=0;i<rd_count;i++) 216 for (unsigned int i=0;i<rd_count;i++)
217 if (0 == (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE)) 217 {
218 { 218 if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE))
219 rd_public[rd_public_count] = rd[i]; 219 continue;
220 if (rd_public[rd_public_count].expiration_time < now.abs_value_us) 220 if ( (0 == (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) &&
221 { 221 (rd[i].expiration_time < now.abs_value_us) )
222 /* record already expired, skip it */ 222 continue; /* record already expired, skip it */
223 continue; 223 rd_public[rd_public_count++] = rd[i];
224 } 224 }
225 rd_public_count++;
226 }
227 return rd_public_count; 225 return rd_public_count;
228} 226}
229 227
diff --git a/src/zonemaster/gnunet-service-zonemaster.c b/src/zonemaster/gnunet-service-zonemaster.c
index 0a562beb1..81d6fa2d9 100644
--- a/src/zonemaster/gnunet-service-zonemaster.c
+++ b/src/zonemaster/gnunet-service-zonemaster.c
@@ -540,24 +540,22 @@ convert_records_for_export (const struct GNUNET_GNSRECORD_Data *rd,
540 rd_public_count = 0; 540 rd_public_count = 0;
541 now = GNUNET_TIME_absolute_get (); 541 now = GNUNET_TIME_absolute_get ();
542 for (unsigned int i=0;i<rd_count;i++) 542 for (unsigned int i=0;i<rd_count;i++)
543 if (0 == (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE)) 543 {
544 if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE))
545 continue;
546 if ( (0 == (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) &&
547 (rd[i].expiration_time < now.abs_value_us) )
548 continue; /* record already expired, skip it */
549 if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
544 { 550 {
545 rd_public[rd_public_count] = rd[i]; 551 /* GNUNET_GNSRECORD_block_create will convert to absolute time;
546 if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) 552 we just need to adjust our iteration frequency */
547 { 553 min_relative_record_time.rel_value_us =
548 /* GNUNET_GNSRECORD_block_create will convert to absolute time; 554 GNUNET_MIN (rd[i].expiration_time,
549 we just need to adjust our iteration frequency */ 555 min_relative_record_time.rel_value_us);
550 min_relative_record_time.rel_value_us =
551 GNUNET_MIN (rd_public[rd_public_count].expiration_time,
552 min_relative_record_time.rel_value_us);
553 }
554 else if (rd_public[rd_public_count].expiration_time < now.abs_value_us)
555 {
556 /* record already expired, skip it */
557 continue;
558 }
559 rd_public_count++;
560 } 556 }
557 rd_public[rd_public_count++] = rd[i];
558 }
561 return rd_public_count; 559 return rd_public_count;
562} 560}
563 561