Bitcoin Core Fuzz Coverage Report

Coverage Report

Created: 2026-03-24 13:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/root/bitcoin/src/clientversion.cpp
Line
Count
Source
1
// Copyright (c) 2012-present The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
#include <bitcoin-build-config.h> // IWYU pragma: keep
6
7
#include <clientversion.h>
8
9
#include <util/string.h>
10
#include <util/translation.h>
11
12
#include <tinyformat.h>
13
14
#include <string>
15
#include <vector>
16
17
using util::Join;
18
19
/**
20
 * Name of client reported in the 'version' message. Report the same name
21
 * for both bitcoind and bitcoin-qt, to make it harder for attackers to
22
 * target servers or GUI users specifically.
23
 */
24
const std::string UA_NAME("Satoshi");
25
26
27
#include <bitcoin-build-info.h>
28
// The <bitcoin-build-info.h>, which is generated by the build environment (cmake/script/GenerateBuildInfo.cmake),
29
// could contain only one line of the following:
30
//   - "#define BUILD_GIT_TAG ...", if the top commit is tagged
31
//   - "#define BUILD_GIT_COMMIT ...", if the top commit is not tagged
32
//   - "// No build information available", if proper git information is not available
33
34
// git will expand the next line to "#define GIT_COMMIT_ID ..." inside archives:
35
//$Format:%n#define GIT_COMMIT_ID "%H"$
36
37
#ifdef BUILD_GIT_TAG
38
    #define BUILD_DESC BUILD_GIT_TAG
39
    #define BUILD_SUFFIX ""
40
#else
41
0
    #define BUILD_DESC "v" CLIENT_VERSION_STRING
42
    #if CLIENT_VERSION_IS_RELEASE
43
        #define BUILD_SUFFIX ""
44
    #elif defined(BUILD_GIT_COMMIT)
45
0
        #define BUILD_SUFFIX "-" BUILD_GIT_COMMIT
46
    #elif defined(GIT_COMMIT_ID)
47
        #define BUILD_SUFFIX "-g" GIT_COMMIT_ID
48
    #else
49
        #define BUILD_SUFFIX "-unk"
50
    #endif
51
#endif
52
53
static std::string FormatVersion(int nVersion)
54
0
{
55
0
    return strprintf("%d.%d.%d", nVersion / 10000, (nVersion / 100) % 100, nVersion % 100);
Line
Count
Source
1172
0
#define strprintf tfm::format
56
0
}
57
58
std::string FormatFullVersion()
59
0
{
60
0
    static const std::string CLIENT_BUILD(BUILD_DESC BUILD_SUFFIX);
Line
Count
Source
41
0
    #define BUILD_DESC "v" CLIENT_VERSION_STRING
    static const std::string CLIENT_BUILD(BUILD_DESC BUILD_SUFFIX);
Line
Count
Source
45
0
        #define BUILD_SUFFIX "-" BUILD_GIT_COMMIT
Line
Count
Source
1
0
#define BUILD_GIT_COMMIT "b75223bfb372"
61
0
    return CLIENT_BUILD;
62
0
}
63
64
/**
65
 * Format the subversion field according to BIP 14 spec (https://github.com/bitcoin/bips/blob/master/bip-0014.mediawiki)
66
 */
67
std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments)
68
0
{
69
0
    std::string comments_str;
70
0
    if (!comments.empty()) comments_str = strprintf("(%s)", Join(comments, "; "));
Line
Count
Source
1172
0
#define strprintf tfm::format
71
0
    return strprintf("/%s:%s%s/", name, FormatVersion(nClientVersion), comments_str);
Line
Count
Source
1172
0
#define strprintf tfm::format
72
0
}
73
74
std::string CopyrightHolders(const std::string& strPrefix)
75
0
{
76
0
    const auto copyright_devs = strprintf(_(COPYRIGHT_HOLDERS), COPYRIGHT_HOLDERS_SUBSTITUTION).translated;
Line
Count
Source
1172
0
#define strprintf tfm::format
    const auto copyright_devs = strprintf(_(COPYRIGHT_HOLDERS), COPYRIGHT_HOLDERS_SUBSTITUTION).translated;
Line
Count
Source
21
0
#define COPYRIGHT_HOLDERS "The %s developers"
    const auto copyright_devs = strprintf(_(COPYRIGHT_HOLDERS), COPYRIGHT_HOLDERS_SUBSTITUTION).translated;
Line
Count
Source
27
0
#define COPYRIGHT_HOLDERS_SUBSTITUTION "Bitcoin Core"
77
0
    std::string strCopyrightHolders = strPrefix + copyright_devs;
78
79
    // Make sure Bitcoin Core copyright is not removed by accident
80
0
    if (copyright_devs.find("Bitcoin Core") == std::string::npos) {
81
0
        strCopyrightHolders += "\n" + strPrefix + "The Bitcoin Core developers";
82
0
    }
83
0
    return strCopyrightHolders;
84
0
}
85
86
std::string LicenseInfo()
87
0
{
88
0
    const std::string URL_SOURCE_CODE = "<https://github.com/bitcoin/bitcoin>";
89
90
0
    return CopyrightHolders(strprintf(_("Copyright (C) %i-%i"), 2009, COPYRIGHT_YEAR).translated + " ") + "\n" +
Line
Count
Source
1172
0
#define strprintf tfm::format
    return CopyrightHolders(strprintf(_("Copyright (C) %i-%i"), 2009, COPYRIGHT_YEAR).translated + " ") + "\n" +
Line
Count
Source
30
0
#define COPYRIGHT_YEAR 2026
91
0
           "\n" +
92
0
           strprintf(_("Please contribute if you find %s useful. "
Line
Count
Source
1172
0
#define strprintf tfm::format
93
0
                       "Visit %s for further information about the software."),
94
0
                     CLIENT_NAME, "<" CLIENT_URL ">")
Line
Count
Source
98
0
#define CLIENT_NAME "Bitcoin Core"
95
0
               .translated +
96
0
           "\n" +
97
0
           strprintf(_("The source code is available from %s."), URL_SOURCE_CODE).translated +
Line
Count
Source
1172
0
#define strprintf tfm::format
98
0
           "\n" +
99
0
           "\n" +
100
0
           _("This is experimental software.") + "\n" +
101
0
           strprintf(_("Distributed under the MIT software license, see the accompanying file %s or %s"), "COPYING", "<https://opensource.org/license/MIT>").translated +
Line
Count
Source
1172
0
#define strprintf tfm::format
102
0
           "\n";
103
0
}