• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

randombit / botan / 22764397870

06 Mar 2026 12:56PM UTC coverage: 90.273% (+0.004%) from 90.269%
22764397870

push

github

web-flow
Merge pull request #5415 from OwenSanzas/fix/gcd-fuzzer-input-split

Fix input split bug in gcd fuzzer

103623 of 114788 relevant lines covered (90.27%)

11729066.07 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.0
/src/fuzzer/gcd.cpp
1
/*
2
* (C) 2021 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/numthry.h>
10

11
namespace {
12

13
Botan::BigInt ref_gcd(Botan::BigInt a, Botan::BigInt b) {
257✔
14
   Botan::BigInt t;
257✔
15
   while(b != 0) {
77,214✔
16
      t = a % b;
76,957✔
17
      t.swap(b);
76,957✔
18
      t.swap(a);
76,957✔
19
   }
20
   return a;
257✔
21
}
257✔
22

23
}  // namespace
24

25
void fuzz(std::span<const uint8_t> in) {
1,000✔
26
   static const size_t max_bits = 4096;
1,000✔
27

28
   if(2 * in.size() * 8 > max_bits) {
1,000✔
29
      return;
743✔
30
   }
31

32
   const size_t half = in.size() / 2;
257✔
33
   const Botan::BigInt x = Botan::BigInt::from_bytes(in.subspan(0, half));
257✔
34
   const Botan::BigInt y = Botan::BigInt::from_bytes(in.subspan(half, in.size() - half));
257✔
35

36
   const Botan::BigInt ref = ref_gcd(x, y);
257✔
37
   const Botan::BigInt lib = Botan::gcd(x, y);
257✔
38

39
   if(ref != lib) {
257✔
40
      FUZZER_WRITE_AND_CRASH("X = " << x.to_hex_string() << "\n"
×
41
                                    << "Y = " << y.to_hex_string() << "\n"
42
                                    << "L = " << lib.to_hex_string() << "\n"
43
                                    << "R = " << ref.to_hex_string() << "\n");
44
   }
45
}
257✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc