rendcache.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. /* Copyright (c) 2015, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. /**
  4. * \file rendcache.c
  5. * \brief Hidden service desriptor cache.
  6. **/
  7. #include "rendcache.h"
  8. #include "config.h"
  9. #include "rendcommon.h"
  10. #include "rephist.h"
  11. #include "routerlist.h"
  12. #include "routerparse.h"
  13. /** Map from service id (as generated by rend_get_service_id) to
  14. * rend_cache_entry_t. */
  15. static strmap_t *rend_cache = NULL;
  16. /** Map from descriptor id to rend_cache_entry_t; only for hidden service
  17. * directories. */
  18. static digestmap_t *rend_cache_v2_dir = NULL;
  19. /** DOCDOC */
  20. static size_t rend_cache_total_allocation = 0;
  21. /** Initializes the service descriptor cache.
  22. */
  23. void
  24. rend_cache_init(void)
  25. {
  26. rend_cache = strmap_new();
  27. rend_cache_v2_dir = digestmap_new();
  28. }
  29. /** Return the approximate number of bytes needed to hold <b>e</b>. */
  30. static size_t
  31. rend_cache_entry_allocation(const rend_cache_entry_t *e)
  32. {
  33. if (!e)
  34. return 0;
  35. /* This doesn't count intro_nodes or key size */
  36. return sizeof(*e) + e->len + sizeof(*e->parsed);
  37. }
  38. /** DOCDOC */
  39. size_t
  40. rend_cache_get_total_allocation(void)
  41. {
  42. return rend_cache_total_allocation;
  43. }
  44. /** Decrement the total bytes attributed to the rendezvous cache by n. */
  45. static void
  46. rend_cache_decrement_allocation(size_t n)
  47. {
  48. static int have_underflowed = 0;
  49. if (rend_cache_total_allocation >= n) {
  50. rend_cache_total_allocation -= n;
  51. } else {
  52. rend_cache_total_allocation = 0;
  53. if (! have_underflowed) {
  54. have_underflowed = 1;
  55. log_warn(LD_BUG, "Underflow in rend_cache_decrement_allocation");
  56. }
  57. }
  58. }
  59. /** Increase the total bytes attributed to the rendezvous cache by n. */
  60. static void
  61. rend_cache_increment_allocation(size_t n)
  62. {
  63. static int have_overflowed = 0;
  64. if (rend_cache_total_allocation <= SIZE_MAX - n) {
  65. rend_cache_total_allocation += n;
  66. } else {
  67. rend_cache_total_allocation = SIZE_MAX;
  68. if (! have_overflowed) {
  69. have_overflowed = 1;
  70. log_warn(LD_BUG, "Overflow in rend_cache_increment_allocation");
  71. }
  72. }
  73. }
  74. /** Helper: free storage held by a single service descriptor cache entry. */
  75. static void
  76. rend_cache_entry_free(rend_cache_entry_t *e)
  77. {
  78. if (!e)
  79. return;
  80. rend_cache_decrement_allocation(rend_cache_entry_allocation(e));
  81. rend_service_descriptor_free(e->parsed);
  82. tor_free(e->desc);
  83. tor_free(e);
  84. }
  85. /** Helper: deallocate a rend_cache_entry_t. (Used with strmap_free(), which
  86. * requires a function pointer whose argument is void*). */
  87. static void
  88. rend_cache_entry_free_(void *p)
  89. {
  90. rend_cache_entry_free(p);
  91. }
  92. /** Free all storage held by the service descriptor cache. */
  93. void
  94. rend_cache_free_all(void)
  95. {
  96. strmap_free(rend_cache, rend_cache_entry_free_);
  97. digestmap_free(rend_cache_v2_dir, rend_cache_entry_free_);
  98. rend_cache = NULL;
  99. rend_cache_v2_dir = NULL;
  100. rend_cache_total_allocation = 0;
  101. }
  102. /** Removes all old entries from the service descriptor cache.
  103. */
  104. void
  105. rend_cache_clean(time_t now)
  106. {
  107. strmap_iter_t *iter;
  108. const char *key;
  109. void *val;
  110. rend_cache_entry_t *ent;
  111. time_t cutoff = now - REND_CACHE_MAX_AGE - REND_CACHE_MAX_SKEW;
  112. for (iter = strmap_iter_init(rend_cache); !strmap_iter_done(iter); ) {
  113. strmap_iter_get(iter, &key, &val);
  114. ent = (rend_cache_entry_t*)val;
  115. if (ent->parsed->timestamp < cutoff) {
  116. iter = strmap_iter_next_rmv(rend_cache, iter);
  117. rend_cache_entry_free(ent);
  118. } else {
  119. iter = strmap_iter_next(rend_cache, iter);
  120. }
  121. }
  122. }
  123. /** Remove ALL entries from the rendezvous service descriptor cache.
  124. */
  125. void
  126. rend_cache_purge(void)
  127. {
  128. if (rend_cache) {
  129. log_info(LD_REND, "Purging HS descriptor cache");
  130. strmap_free(rend_cache, rend_cache_entry_free_);
  131. }
  132. rend_cache = strmap_new();
  133. }
  134. /** Remove all old v2 descriptors and those for which this hidden service
  135. * directory is not responsible for any more.
  136. *
  137. * If at all possible, remove at least <b>force_remove</b> bytes of data.
  138. */
  139. void
  140. rend_cache_clean_v2_descs_as_dir(time_t now, size_t force_remove)
  141. {
  142. digestmap_iter_t *iter;
  143. time_t cutoff = now - REND_CACHE_MAX_AGE - REND_CACHE_MAX_SKEW;
  144. const int LAST_SERVED_CUTOFF_STEP = 1800;
  145. time_t last_served_cutoff = cutoff;
  146. size_t bytes_removed = 0;
  147. do {
  148. for (iter = digestmap_iter_init(rend_cache_v2_dir);
  149. !digestmap_iter_done(iter); ) {
  150. const char *key;
  151. void *val;
  152. rend_cache_entry_t *ent;
  153. digestmap_iter_get(iter, &key, &val);
  154. ent = val;
  155. if (ent->parsed->timestamp < cutoff ||
  156. ent->last_served < last_served_cutoff ||
  157. !hid_serv_responsible_for_desc_id(key)) {
  158. char key_base32[REND_DESC_ID_V2_LEN_BASE32 + 1];
  159. base32_encode(key_base32, sizeof(key_base32), key, DIGEST_LEN);
  160. log_info(LD_REND, "Removing descriptor with ID '%s' from cache",
  161. safe_str_client(key_base32));
  162. bytes_removed += rend_cache_entry_allocation(ent);
  163. iter = digestmap_iter_next_rmv(rend_cache_v2_dir, iter);
  164. rend_cache_entry_free(ent);
  165. } else {
  166. iter = digestmap_iter_next(rend_cache_v2_dir, iter);
  167. }
  168. }
  169. /* In case we didn't remove enough bytes, advance the cutoff a little. */
  170. last_served_cutoff += LAST_SERVED_CUTOFF_STEP;
  171. if (last_served_cutoff > now)
  172. break;
  173. } while (bytes_removed < force_remove);
  174. }
  175. /** Lookup in the client cache the given service ID <b>query</b> for
  176. * <b>version</b>.
  177. *
  178. * Return 0 if found and if <b>e</b> is non NULL, set it with the entry
  179. * found. Else, a negative value is returned and <b>e</b> is untouched.
  180. * -EINVAL means that <b>query</b> is not a valid service id.
  181. * -ENOENT means that no entry in the cache was found. */
  182. int
  183. rend_cache_lookup_entry(const char *query, int version, rend_cache_entry_t **e)
  184. {
  185. int ret = 0;
  186. char key[REND_SERVICE_ID_LEN_BASE32 + 2]; /* <version><query>\0 */
  187. rend_cache_entry_t *entry = NULL;
  188. static const int default_version = 2;
  189. tor_assert(rend_cache);
  190. tor_assert(query);
  191. if (!rend_valid_service_id(query)) {
  192. ret = -EINVAL;
  193. goto end;
  194. }
  195. switch (version) {
  196. case 0:
  197. log_warn(LD_REND, "Cache lookup of a v0 renddesc is deprecated.");
  198. break;
  199. case 2:
  200. /* Default is version 2. */
  201. default:
  202. tor_snprintf(key, sizeof(key), "%d%s", default_version, query);
  203. entry = strmap_get_lc(rend_cache, key);
  204. break;
  205. }
  206. if (!entry) {
  207. ret = -ENOENT;
  208. goto end;
  209. }
  210. tor_assert(entry->parsed && entry->parsed->intro_nodes);
  211. if (e) {
  212. *e = entry;
  213. }
  214. end:
  215. return ret;
  216. }
  217. /** Lookup the v2 service descriptor with base32-encoded <b>desc_id</b> and
  218. * copy the pointer to it to *<b>desc</b>. Return 1 on success, 0 on
  219. * well-formed-but-not-found, and -1 on failure.
  220. */
  221. int
  222. rend_cache_lookup_v2_desc_as_dir(const char *desc_id, const char **desc)
  223. {
  224. rend_cache_entry_t *e;
  225. char desc_id_digest[DIGEST_LEN];
  226. tor_assert(rend_cache_v2_dir);
  227. if (base32_decode(desc_id_digest, DIGEST_LEN,
  228. desc_id, REND_DESC_ID_V2_LEN_BASE32) < 0) {
  229. log_fn(LOG_PROTOCOL_WARN, LD_REND,
  230. "Rejecting v2 rendezvous descriptor request -- descriptor ID "
  231. "contains illegal characters: %s",
  232. safe_str(desc_id));
  233. return -1;
  234. }
  235. /* Lookup descriptor and return. */
  236. e = digestmap_get(rend_cache_v2_dir, desc_id_digest);
  237. if (e) {
  238. *desc = e->desc;
  239. e->last_served = approx_time();
  240. return 1;
  241. }
  242. return 0;
  243. }
  244. /** Parse the v2 service descriptor(s) in <b>desc</b> and store it/them to the
  245. * local rend cache. Don't attempt to decrypt the included list of introduction
  246. * points (as we don't have a descriptor cookie for it).
  247. *
  248. * If we have a newer descriptor with the same ID, ignore this one.
  249. * If we have an older descriptor with the same ID, replace it.
  250. *
  251. * Return an appropriate rend_cache_store_status_t.
  252. */
  253. rend_cache_store_status_t
  254. rend_cache_store_v2_desc_as_dir(const char *desc)
  255. {
  256. const or_options_t *options = get_options();
  257. rend_service_descriptor_t *parsed;
  258. char desc_id[DIGEST_LEN];
  259. char *intro_content;
  260. size_t intro_size;
  261. size_t encoded_size;
  262. char desc_id_base32[REND_DESC_ID_V2_LEN_BASE32 + 1];
  263. int number_parsed = 0, number_stored = 0;
  264. const char *current_desc = desc;
  265. const char *next_desc;
  266. rend_cache_entry_t *e;
  267. time_t now = time(NULL);
  268. tor_assert(rend_cache_v2_dir);
  269. tor_assert(desc);
  270. if (!hid_serv_acting_as_directory()) {
  271. /* Cannot store descs, because we are (currently) not acting as
  272. * hidden service directory. */
  273. log_info(LD_REND, "Cannot store descs: Not acting as hs dir");
  274. return RCS_NOTDIR;
  275. }
  276. while (rend_parse_v2_service_descriptor(&parsed, desc_id, &intro_content,
  277. &intro_size, &encoded_size,
  278. &next_desc, current_desc, 1) >= 0) {
  279. number_parsed++;
  280. /* We don't care about the introduction points. */
  281. tor_free(intro_content);
  282. /* For pretty log statements. */
  283. base32_encode(desc_id_base32, sizeof(desc_id_base32),
  284. desc_id, DIGEST_LEN);
  285. /* Is desc ID in the range that we are (directly or indirectly) responsible
  286. * for? */
  287. if (!hid_serv_responsible_for_desc_id(desc_id)) {
  288. log_info(LD_REND, "Service descriptor with desc ID %s is not in "
  289. "interval that we are responsible for.",
  290. safe_str_client(desc_id_base32));
  291. goto skip;
  292. }
  293. /* Is descriptor too old? */
  294. if (parsed->timestamp < now - REND_CACHE_MAX_AGE-REND_CACHE_MAX_SKEW) {
  295. log_info(LD_REND, "Service descriptor with desc ID %s is too old.",
  296. safe_str(desc_id_base32));
  297. goto skip;
  298. }
  299. /* Is descriptor too far in the future? */
  300. if (parsed->timestamp > now + REND_CACHE_MAX_SKEW) {
  301. log_info(LD_REND, "Service descriptor with desc ID %s is too far in the "
  302. "future.",
  303. safe_str(desc_id_base32));
  304. goto skip;
  305. }
  306. /* Do we already have a newer descriptor? */
  307. e = digestmap_get(rend_cache_v2_dir, desc_id);
  308. if (e && e->parsed->timestamp > parsed->timestamp) {
  309. log_info(LD_REND, "We already have a newer service descriptor with the "
  310. "same desc ID %s and version.",
  311. safe_str(desc_id_base32));
  312. goto skip;
  313. }
  314. /* Do we already have this descriptor? */
  315. if (e && !strcmp(desc, e->desc)) {
  316. log_info(LD_REND, "We already have this service descriptor with desc "
  317. "ID %s.", safe_str(desc_id_base32));
  318. goto skip;
  319. }
  320. /* Store received descriptor. */
  321. if (!e) {
  322. e = tor_malloc_zero(sizeof(rend_cache_entry_t));
  323. digestmap_set(rend_cache_v2_dir, desc_id, e);
  324. /* Treat something just uploaded as having been served a little
  325. * while ago, so that flooding with new descriptors doesn't help
  326. * too much.
  327. */
  328. e->last_served = approx_time() - 3600;
  329. } else {
  330. rend_cache_decrement_allocation(rend_cache_entry_allocation(e));
  331. rend_service_descriptor_free(e->parsed);
  332. tor_free(e->desc);
  333. }
  334. e->parsed = parsed;
  335. e->desc = tor_strndup(current_desc, encoded_size);
  336. e->len = encoded_size;
  337. rend_cache_increment_allocation(rend_cache_entry_allocation(e));
  338. log_info(LD_REND, "Successfully stored service descriptor with desc ID "
  339. "'%s' and len %d.",
  340. safe_str(desc_id_base32), (int)encoded_size);
  341. /* Statistics: Note down this potentially new HS. */
  342. if (options->HiddenServiceStatistics) {
  343. rep_hist_stored_maybe_new_hs(e->parsed->pk);
  344. }
  345. number_stored++;
  346. goto advance;
  347. skip:
  348. rend_service_descriptor_free(parsed);
  349. advance:
  350. /* advance to next descriptor, if available. */
  351. current_desc = next_desc;
  352. /* check if there is a next descriptor. */
  353. if (!current_desc ||
  354. strcmpstart(current_desc, "rendezvous-service-descriptor "))
  355. break;
  356. }
  357. if (!number_parsed) {
  358. log_info(LD_REND, "Could not parse any descriptor.");
  359. return RCS_BADDESC;
  360. }
  361. log_info(LD_REND, "Parsed %d and added %d descriptor%s.",
  362. number_parsed, number_stored, number_stored != 1 ? "s" : "");
  363. return RCS_OKAY;
  364. }
  365. /** Parse the v2 service descriptor in <b>desc</b>, decrypt the included list
  366. * of introduction points with <b>descriptor_cookie</b> (which may also be
  367. * <b>NULL</b> if decryption is not necessary), and store the descriptor to
  368. * the local cache under its version and service id.
  369. *
  370. * If we have a newer v2 descriptor with the same ID, ignore this one.
  371. * If we have an older descriptor with the same ID, replace it.
  372. * If the descriptor's service ID does not match
  373. * <b>rend_query</b>-\>onion_address, reject it.
  374. *
  375. * If the descriptor's descriptor ID doesn't match <b>desc_id_base32</b>,
  376. * reject it.
  377. *
  378. * Return an appropriate rend_cache_store_status_t. If entry is not NULL,
  379. * set it with the cache entry pointer of the descriptor.
  380. */
  381. rend_cache_store_status_t
  382. rend_cache_store_v2_desc_as_client(const char *desc,
  383. const char *desc_id_base32,
  384. const rend_data_t *rend_query,
  385. rend_cache_entry_t **entry)
  386. {
  387. /*XXXX this seems to have a bit of duplicate code with
  388. * rend_cache_store_v2_desc_as_dir(). Fix that. */
  389. /* Though having similar elements, both functions were separated on
  390. * purpose:
  391. * - dirs don't care about encoded/encrypted introduction points, clients
  392. * do.
  393. * - dirs store descriptors in a separate cache by descriptor ID, whereas
  394. * clients store them by service ID; both caches are different data
  395. * structures and have different access methods.
  396. * - dirs store a descriptor only if they are responsible for its ID,
  397. * clients do so in every way (because they have requested it before).
  398. * - dirs can process multiple concatenated descriptors which is required
  399. * for replication, whereas clients only accept a single descriptor.
  400. * Thus, combining both methods would result in a lot of if statements
  401. * which probably would not improve, but worsen code readability. -KL */
  402. rend_service_descriptor_t *parsed = NULL;
  403. char desc_id[DIGEST_LEN];
  404. char *intro_content = NULL;
  405. size_t intro_size;
  406. size_t encoded_size;
  407. const char *next_desc;
  408. time_t now = time(NULL);
  409. char key[REND_SERVICE_ID_LEN_BASE32+2];
  410. char service_id[REND_SERVICE_ID_LEN_BASE32+1];
  411. char want_desc_id[DIGEST_LEN];
  412. rend_cache_entry_t *e;
  413. rend_cache_store_status_t retval = RCS_BADDESC;
  414. tor_assert(rend_cache);
  415. tor_assert(desc);
  416. tor_assert(desc_id_base32);
  417. memset(want_desc_id, 0, sizeof(want_desc_id));
  418. if (entry) {
  419. *entry = NULL;
  420. }
  421. if (base32_decode(want_desc_id, sizeof(want_desc_id),
  422. desc_id_base32, strlen(desc_id_base32)) != 0) {
  423. log_warn(LD_BUG, "Couldn't decode base32 %s for descriptor id.",
  424. escaped_safe_str_client(desc_id_base32));
  425. goto err;
  426. }
  427. /* Parse the descriptor. */
  428. if (rend_parse_v2_service_descriptor(&parsed, desc_id, &intro_content,
  429. &intro_size, &encoded_size,
  430. &next_desc, desc, 0) < 0) {
  431. log_warn(LD_REND, "Could not parse descriptor.");
  432. goto err;
  433. }
  434. /* Compute service ID from public key. */
  435. if (rend_get_service_id(parsed->pk, service_id)<0) {
  436. log_warn(LD_REND, "Couldn't compute service ID.");
  437. goto err;
  438. }
  439. if (rend_query->onion_address[0] != '\0' &&
  440. strcmp(rend_query->onion_address, service_id)) {
  441. log_warn(LD_REND, "Received service descriptor for service ID %s; "
  442. "expected descriptor for service ID %s.",
  443. service_id, safe_str(rend_query->onion_address));
  444. goto err;
  445. }
  446. if (tor_memneq(desc_id, want_desc_id, DIGEST_LEN)) {
  447. log_warn(LD_REND, "Received service descriptor for %s with incorrect "
  448. "descriptor ID.", service_id);
  449. goto err;
  450. }
  451. /* Decode/decrypt introduction points. */
  452. if (intro_content && intro_size > 0) {
  453. int n_intro_points;
  454. if (rend_query->auth_type != REND_NO_AUTH &&
  455. !tor_mem_is_zero(rend_query->descriptor_cookie,
  456. sizeof(rend_query->descriptor_cookie))) {
  457. char *ipos_decrypted = NULL;
  458. size_t ipos_decrypted_size;
  459. if (rend_decrypt_introduction_points(&ipos_decrypted,
  460. &ipos_decrypted_size,
  461. rend_query->descriptor_cookie,
  462. intro_content,
  463. intro_size) < 0) {
  464. log_warn(LD_REND, "Failed to decrypt introduction points. We are "
  465. "probably unable to parse the encoded introduction points.");
  466. } else {
  467. /* Replace encrypted with decrypted introduction points. */
  468. log_info(LD_REND, "Successfully decrypted introduction points.");
  469. tor_free(intro_content);
  470. intro_content = ipos_decrypted;
  471. intro_size = ipos_decrypted_size;
  472. }
  473. }
  474. n_intro_points = rend_parse_introduction_points(parsed, intro_content,
  475. intro_size);
  476. if (n_intro_points <= 0) {
  477. log_warn(LD_REND, "Failed to parse introduction points. Either the "
  478. "service has published a corrupt descriptor or you have "
  479. "provided invalid authorization data.");
  480. goto err;
  481. } else if (n_intro_points > MAX_INTRO_POINTS) {
  482. log_warn(LD_REND, "Found too many introduction points on a hidden "
  483. "service descriptor for %s. This is probably a (misguided) "
  484. "attempt to improve reliability, but it could also be an "
  485. "attempt to do a guard enumeration attack. Rejecting.",
  486. safe_str_client(service_id));
  487. goto err;
  488. }
  489. } else {
  490. log_info(LD_REND, "Descriptor does not contain any introduction points.");
  491. parsed->intro_nodes = smartlist_new();
  492. }
  493. /* We don't need the encoded/encrypted introduction points any longer. */
  494. tor_free(intro_content);
  495. /* Is descriptor too old? */
  496. if (parsed->timestamp < now - REND_CACHE_MAX_AGE-REND_CACHE_MAX_SKEW) {
  497. log_warn(LD_REND, "Service descriptor with service ID %s is too old.",
  498. safe_str_client(service_id));
  499. goto err;
  500. }
  501. /* Is descriptor too far in the future? */
  502. if (parsed->timestamp > now + REND_CACHE_MAX_SKEW) {
  503. log_warn(LD_REND, "Service descriptor with service ID %s is too far in "
  504. "the future.", safe_str_client(service_id));
  505. goto err;
  506. }
  507. /* Do we already have a newer descriptor? */
  508. tor_snprintf(key, sizeof(key), "2%s", service_id);
  509. e = (rend_cache_entry_t*) strmap_get_lc(rend_cache, key);
  510. if (e && e->parsed->timestamp >= parsed->timestamp) {
  511. log_info(LD_REND, "We already have a new enough service descriptor for "
  512. "service ID %s with the same desc ID and version.",
  513. safe_str_client(service_id));
  514. goto okay;
  515. }
  516. if (!e) {
  517. e = tor_malloc_zero(sizeof(rend_cache_entry_t));
  518. strmap_set_lc(rend_cache, key, e);
  519. } else {
  520. rend_cache_decrement_allocation(rend_cache_entry_allocation(e));
  521. rend_service_descriptor_free(e->parsed);
  522. tor_free(e->desc);
  523. }
  524. e->parsed = parsed;
  525. e->desc = tor_malloc_zero(encoded_size + 1);
  526. strlcpy(e->desc, desc, encoded_size + 1);
  527. e->len = encoded_size;
  528. rend_cache_increment_allocation(rend_cache_entry_allocation(e));
  529. log_debug(LD_REND,"Successfully stored rend desc '%s', len %d.",
  530. safe_str_client(service_id), (int)encoded_size);
  531. if (entry) {
  532. *entry = e;
  533. }
  534. return RCS_OKAY;
  535. okay:
  536. if (entry) {
  537. *entry = e;
  538. }
  539. retval = RCS_OKAY;
  540. err:
  541. rend_service_descriptor_free(parsed);
  542. tor_free(intro_content);
  543. return retval;
  544. }