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

randombit / botan / 22740733591

05 Mar 2026 10:56PM UTC coverage: 90.267% (-1.6%) from 91.906%
22740733591

Pull #5415

github

web-flow
Merge d7d916585 into b47e9d96d
Pull Request #5415: Fix input split bug in gcd fuzzer

103616 of 114788 relevant lines covered (90.27%)

11561964.13 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,290✔
16
      t = a % b;
77,033✔
17
      t.swap(b);
77,033✔
18
      t.swap(a);
77,033✔
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