Coverage Report

Created: 2025-04-11 06:34

/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
9
#include <botan/ber_dec.h>
10
#include <botan/pkix_types.h>
11
12
2.33k
void fuzz(std::span<const uint8_t> in) {
13
2.33k
   Botan::X509_DN dn1;
14
2.33k
   Botan::X509_DN dn2;
15
16
2.33k
   try {
17
2.33k
      Botan::BER_Decoder ber(in);
18
2.33k
      dn1.decode_from(ber);
19
2.33k
      dn2.decode_from(ber);
20
2.33k
   } catch(...) {
21
1.69k
      return;
22
1.69k
   }
23
24
643
   const bool eq = dn1 == dn2;
25
643
   const bool lt1 = dn1 < dn2;
26
643
   const bool lt2 = dn2 < dn1;
27
28
643
   if(lt1 == false && lt2 == false) {
29
66
      FUZZER_ASSERT_TRUE(eq);
30
577
   } else {
31
      // one is less than the other
32
577
      FUZZER_ASSERT_TRUE(lt1 || lt2);
33
34
      // it is not the case that both are less than the other
35
577
      FUZZER_ASSERT_TRUE(!lt1 || !lt2);
36
577
   }
37
643
}