Coverage Report

Created: 2020-05-23 13:54

/src/botan/src/fuzzer/x509_dn.cpp
Line
Count
Source
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/x509_dn.h>
9
#include <botan/ber_dec.h>
10
#include <botan/hex.h>
11
12
void fuzz(const uint8_t in[], size_t len)
13
2.02k
   {
14
2.02k
   Botan::X509_DN dn1;
15
2.02k
   Botan::X509_DN dn2;
16
2.02k
17
2.02k
   try
18
2.02k
      {
19
2.02k
      Botan::BER_Decoder ber(in, len);
20
2.02k
      dn1.decode_from(ber);
21
2.02k
      dn2.decode_from(ber);
22
2.02k
      }
23
2.02k
   catch(...) { return; }
24
622
25
622
   const bool eq = dn1 == dn2;
26
622
   const bool lt1 = dn1 < dn2;
27
622
   const bool lt2 = dn2 < dn1;
28
622
29
622
   if(lt1 == false && lt2 == false)
30
47
      {
31
47
      FUZZER_ASSERT_TRUE(eq);
32
47
      }
33
575
   else
34
575
      {
35
575
      // one is less than the other
36
575
      FUZZER_ASSERT_TRUE(lt1 || lt2);
37
575
38
575
      // it is not the case that both are less than the other
39
575
      FUZZER_ASSERT_TRUE(!lt1 || !lt2);
40
575
      }
41
622
   }