Coverage Report

Created: 2022-06-23 06:44

/src/botan/src/fuzzer/x509_dn.cpp
Line
Count
Source (jump to first uncovered line)
1
/*
2
* (C) 2019 Jack Lloyd
3
*
4
* Botan is released under the Simplified BSD License (see license.txt)
5
*/
6
7
#include "fuzzers.h"
8
#include <botan/pkix_types.h>
9
#include <botan/ber_dec.h>
10
#include <botan/hex.h>
11
12
void fuzz(const uint8_t in[], size_t len)
13
4.33k
   {
14
4.33k
   Botan::X509_DN dn1;
15
4.33k
   Botan::X509_DN dn2;
16
17
4.33k
   try
18
4.33k
      {
19
4.33k
      Botan::BER_Decoder ber(in, len);
20
4.33k
      dn1.decode_from(ber);
21
4.33k
      dn2.decode_from(ber);
22
4.33k
      }
23
4.33k
   catch(...) { return; }
24
25
1.33k
   const bool eq = dn1 == dn2;
26
1.33k
   const bool lt1 = dn1 < dn2;
27
1.33k
   const bool lt2 = dn2 < dn1;
28
29
1.33k
   if(lt1 == false && lt2 == false)
30
134
      {
31
134
      FUZZER_ASSERT_TRUE(eq);
32
134
      }
33
1.20k
   else
34
1.20k
      {
35
      // one is less than the other
36
1.20k
      FUZZER_ASSERT_TRUE(lt1 || lt2);
37
38
      // it is not the case that both are less than the other
39
1.20k
      FUZZER_ASSERT_TRUE(!lt1 || !lt2);
40
1.20k
      }
41
1.33k
   }