tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

fuzz_iptsv2.c (1055B)


      1 /* Copyright (c) 2016-2021, The Tor Project, Inc. */
      2 /* See LICENSE for licensing information */
      3 
      4 #include "core/or/or.h"
      5 #include "feature/dirparse/unparseable.h"
      6 #include "feature/rend/rendcommon.h"
      7 #include "feature/rend/rendparse.h"
      8 #include "lib/crypt_ops/crypto_ed25519.h"
      9 
     10 #include "feature/rend/rend_service_descriptor_st.h"
     11 
     12 #include "test/fuzz/fuzzing.h"
     13 
     14 static void
     15 mock_dump_desc__nodump(const char *desc, const char *type)
     16 {
     17  (void)desc;
     18  (void)type;
     19 }
     20 
     21 int
     22 fuzz_init(void)
     23 {
     24  disable_signature_checking();
     25  MOCK(dump_desc, mock_dump_desc__nodump);
     26  ed25519_init();
     27  return 0;
     28 }
     29 
     30 int
     31 fuzz_cleanup(void)
     32 {
     33  return 0;
     34 }
     35 
     36 int
     37 fuzz_main(const uint8_t *data, size_t sz)
     38 {
     39  rend_service_descriptor_t *desc =
     40    tor_malloc_zero(sizeof(rend_service_descriptor_t));
     41  const char *str = (const char*) data;
     42  int r = rend_parse_introduction_points(desc, str, sz);
     43  if (r >= 0) {
     44    log_debug(LD_GENERAL, "Parsing okay: %d", r);
     45  } else {
     46    log_debug(LD_GENERAL, "Parsing failed");
     47  }
     48  rend_service_descriptor_free(desc);
     49  return 0;
     50 }