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

randombit / botan / 5356685938

23 Jun 2023 01:39PM UTC coverage: 91.746% (+0.02%) from 91.728%
5356685938

push

github

randombit
Merge GH #3595 Apply clang-tidy more universally

Previously clang-tidy ruleset disabled certain rules for the cli and
tests. Remove these exceptions, and fix the relevant warnings.

Also fix compile_commands.json which had previously not provided information for
the examples, BoGo shim, or fuzzers. As a result, clang-tidy was effectively
blind to them. Fix various clang-tidy findings in these files.

Additionally fix clang-tidy warnings that were in Boost or Sqlite3 specific
code, which had been accidentally omitted in past checks.

Modify the nightly clang-tidy run to additionally check the examples, fuzzers,
shim, and Sqlite3/Boost specific code.

78183 of 85217 relevant lines covered (91.75%)

12364366.11 hits per line

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

95.0
/src/fuzzer/bn_cmp.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/bigint.h>
10

11
void fuzz(const uint8_t in[], size_t len) {
1,000✔
12
   const size_t max_bits = 512;
1,000✔
13

14
   if(len < 3 || len > 1 + 2 * (max_bits / 8)) {
1,000✔
15
      return;
873✔
16
   }
17

18
   const uint8_t signs = in[0];
127✔
19
   const size_t x_len = (len - 1) / 2;
127✔
20

21
   Botan::BigInt x = Botan::BigInt::decode(in + 1, x_len);
127✔
22
   Botan::BigInt y = Botan::BigInt::decode(in + 1 + x_len, len - x_len - 1);
127✔
23

24
   if(signs & 1) {
127✔
25
      x.flip_sign();
70✔
26
   }
27
   if(signs & 2) {
127✔
28
      y.flip_sign();
68✔
29
   }
30

31
   const Botan::BigInt d1 = x - y;
127✔
32
   const Botan::BigInt d2 = y - x;
127✔
33

34
   FUZZER_ASSERT_TRUE(d1.cmp(d2, false) == 0);
127✔
35

36
   const bool is_eq = (x == y);
127✔
37
   const bool is_lt = (x < y);
127✔
38
   const bool is_gt = (x > y);
127✔
39
   const bool is_lte = (x <= y);
127✔
40
   const bool is_gte = (x >= y);
127✔
41

42
   if(is_eq) {
127✔
43
      FUZZER_ASSERT_TRUE(d1.is_zero());
×
44
      FUZZER_ASSERT_TRUE(d2.is_zero());
×
45
   }
46

47
   if(is_lte) {
127✔
48
      FUZZER_ASSERT_TRUE(is_lt || is_eq);
63✔
49
   }
50

51
   if(is_gte) {
127✔
52
      FUZZER_ASSERT_TRUE(is_gt || is_eq);
64✔
53
   }
54

55
   if(is_lt) {
127✔
56
      FUZZER_ASSERT_TRUE(!is_gt);
63✔
57
      FUZZER_ASSERT_TRUE(d1.is_nonzero());
63✔
58
      FUZZER_ASSERT_TRUE(d2.is_nonzero());
126✔
59
      FUZZER_ASSERT_TRUE(d1.is_negative());
63✔
60
      FUZZER_ASSERT_TRUE(d2.is_positive());
63✔
61
   }
62

63
   if(is_gt) {
127✔
64
      FUZZER_ASSERT_TRUE(!is_lt);
64✔
65
      FUZZER_ASSERT_TRUE(d1.is_nonzero());
128✔
66
      FUZZER_ASSERT_TRUE(d2.is_nonzero());
64✔
67
      FUZZER_ASSERT_TRUE(d1.is_positive());
64✔
68
      FUZZER_ASSERT_TRUE(d2.is_negative());
64✔
69
   }
70
}
508✔
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

© 2025 Coveralls, Inc