Bitcoin Core Fuzz Coverage Report for wallet_tx_can_be_bumped

Coverage Report

Created: 2025-11-19 11:20

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/Users/brunogarcia/projects/bitcoin-core-dev/src/randomenv.cpp
Line
Count
Source
1
// Copyright (c) 2009-2010 Satoshi Nakamoto
2
// Copyright (c) 2009-2022 The Bitcoin Core developers
3
// Distributed under the MIT software license, see the accompanying
4
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6
#include <bitcoin-build-config.h> // IWYU pragma: keep
7
8
#include <randomenv.h>
9
10
#include <clientversion.h>
11
#include <compat/compat.h>
12
#include <compat/cpuid.h>
13
#include <crypto/sha512.h>
14
#include <span.h>
15
#include <support/cleanse.h>
16
#include <util/time.h>
17
18
#include <algorithm>
19
#include <atomic>
20
#include <cstdint>
21
#include <cstring>
22
#include <chrono>
23
#include <climits>
24
#include <thread>
25
#include <vector>
26
27
#include <sys/types.h> // must go before a number of other headers
28
29
#ifdef WIN32
30
#include <windows.h>
31
#else
32
#include <fcntl.h>
33
#include <netinet/in.h>
34
#include <sys/resource.h>
35
#include <sys/socket.h>
36
#include <sys/stat.h>
37
#include <sys/time.h>
38
#include <sys/utsname.h>
39
#include <unistd.h>
40
#endif
41
#ifdef HAVE_IFADDRS
42
#include <ifaddrs.h>
43
#endif
44
#ifdef HAVE_SYSCTL
45
#include <sys/sysctl.h>
46
#if __has_include(<vm/vm_param.h>)
47
#include <vm/vm_param.h>
48
#endif
49
#if __has_include(<sys/resources.h>)
50
#include <sys/resources.h>
51
#endif
52
#if __has_include(<sys/vmmeter.h>)
53
#include <sys/vmmeter.h>
54
#endif
55
#endif
56
#if defined(HAVE_STRONG_GETAUXVAL)
57
#include <sys/auxv.h>
58
#endif
59
60
#if defined(__APPLE__) || \
61
    defined(__FreeBSD__) || \
62
    defined(__NetBSD__) || \
63
    defined(__OpenBSD__) || \
64
    defined(__illumos__)
65
extern char** environ; // Necessary on the above platforms
66
#endif
67
68
namespace {
69
70
/** Helper to easily feed data into a CSHA512.
71
 *
72
 * Note that this does not serialize the passed object (like stream.h's << operators do).
73
 * Its raw memory representation is used directly.
74
 */
75
template<typename T>
76
0
CSHA512& operator<<(CSHA512& hasher, const T& data) {
77
0
    static_assert(!std::is_same_v<std::decay_t<T>, char*>, "Calling operator<<(CSHA512, char*) is probably not what you want");
78
0
    static_assert(!std::is_same_v<std::decay_t<T>, unsigned char*>, "Calling operator<<(CSHA512, unsigned char*) is probably not what you want");
79
0
    static_assert(!std::is_same_v<std::decay_t<T>, const char*>, "Calling operator<<(CSHA512, const char*) is probably not what you want");
80
0
    static_assert(!std::is_same_v<std::decay_t<T>, const unsigned char*>, "Calling operator<<(CSHA512, const unsigned char*) is probably not what you want");
81
0
    hasher.Write((const unsigned char*)&data, sizeof(data));
82
0
    return hasher;
83
0
}
Unexecuted instantiation: randomenv.cpp:CSHA512& (anonymous namespace)::operator<<<stat>(CSHA512&, stat const&)
Unexecuted instantiation: randomenv.cpp:CSHA512& (anonymous namespace)::operator<<<timespec>(CSHA512&, timespec const&)
Unexecuted instantiation: randomenv.cpp:CSHA512& (anonymous namespace)::operator<<<timeval>(CSHA512&, timeval const&)
Unexecuted instantiation: randomenv.cpp:CSHA512& (anonymous namespace)::operator<<<long long>(CSHA512&, long long const&)
Unexecuted instantiation: randomenv.cpp:CSHA512& (anonymous namespace)::operator<<<rusage>(CSHA512&, rusage const&)
Unexecuted instantiation: randomenv.cpp:CSHA512& (anonymous namespace)::operator<<<void**>(CSHA512&, void** const&)
Unexecuted instantiation: randomenv.cpp:CSHA512& (anonymous namespace)::operator<<<void*>(CSHA512&, void* const&)
Unexecuted instantiation: randomenv.cpp:CSHA512& (anonymous namespace)::operator<<<bool>(CSHA512&, bool const&)
Unexecuted instantiation: randomenv.cpp:CSHA512& (anonymous namespace)::operator<<<unsigned long>(CSHA512&, unsigned long const&)
Unexecuted instantiation: randomenv.cpp:CSHA512& (anonymous namespace)::operator<<<int>(CSHA512&, int const&)
Unexecuted instantiation: randomenv.cpp:CSHA512& (anonymous namespace)::operator<<<long>(CSHA512&, long const&)
Unexecuted instantiation: randomenv.cpp:CSHA512& (anonymous namespace)::operator<<<CSHA512*>(CSHA512&, CSHA512* const&)
Unexecuted instantiation: randomenv.cpp:CSHA512& (anonymous namespace)::operator<<<void (*)(CSHA512&)>(CSHA512&, void (* const&)(CSHA512&))
Unexecuted instantiation: randomenv.cpp:CSHA512& (anonymous namespace)::operator<<<void* (*)(unsigned long)>(CSHA512&, void* (* const&)(unsigned long))
Unexecuted instantiation: randomenv.cpp:CSHA512& (anonymous namespace)::operator<<<int*>(CSHA512&, int* const&)
Unexecuted instantiation: randomenv.cpp:CSHA512& (anonymous namespace)::operator<<<char***>(CSHA512&, char*** const&)
Unexecuted instantiation: randomenv.cpp:CSHA512& (anonymous namespace)::operator<<<unsigned int>(CSHA512&, unsigned int const&)
Unexecuted instantiation: randomenv.cpp:CSHA512& (anonymous namespace)::operator<<<std::__1::__thread_id>(CSHA512&, std::__1::__thread_id const&)
84
85
#ifndef WIN32
86
void AddSockaddr(CSHA512& hasher, const struct sockaddr *addr)
87
0
{
88
0
    if (addr == nullptr) return;
89
0
    switch (addr->sa_family) {
90
0
    case AF_INET:
91
0
        hasher.Write((const unsigned char*)addr, sizeof(sockaddr_in));
92
0
        break;
93
0
    case AF_INET6:
94
0
        hasher.Write((const unsigned char*)addr, sizeof(sockaddr_in6));
95
0
        break;
96
0
    default:
97
0
        hasher.Write((const unsigned char*)&addr->sa_family, sizeof(addr->sa_family));
98
0
    }
99
0
}
100
101
void AddFile(CSHA512& hasher, const char *path)
102
0
{
103
0
    struct stat sb = {};
104
0
    int f = open(path, O_RDONLY);
105
0
    size_t total = 0;
106
0
    if (f != -1) {
107
0
        unsigned char fbuf[4096];
108
0
        int n;
109
0
        hasher.Write((const unsigned char*)&f, sizeof(f));
110
0
        if (fstat(f, &sb) == 0) hasher << sb;
111
0
        do {
112
0
            n = read(f, fbuf, sizeof(fbuf));
113
0
            if (n > 0) hasher.Write(fbuf, n);
114
0
            total += n;
115
            /* not bothering with EINTR handling. */
116
0
        } while (n == sizeof(fbuf) && total < 1048576); // Read only the first 1 Mbyte
117
0
        close(f);
118
0
    }
119
0
}
120
121
void AddPath(CSHA512& hasher, const char *path)
122
0
{
123
0
    struct stat sb = {};
124
0
    if (stat(path, &sb) == 0) {
125
0
        hasher.Write((const unsigned char*)path, strlen(path) + 1);
126
0
        hasher << sb;
127
0
    }
128
0
}
129
#endif
130
131
#ifdef HAVE_SYSCTL
132
template<int... S>
133
void AddSysctl(CSHA512& hasher)
134
0
{
135
0
    int CTL[sizeof...(S)] = {S...};
136
0
    unsigned char buffer[65536];
137
0
    size_t siz = 65536;
138
0
    int ret = sysctl(CTL, sizeof...(S), buffer, &siz, nullptr, 0);
139
0
    if (ret == 0 || (ret == -1 && errno == ENOMEM)) {
140
0
        hasher << sizeof(CTL);
141
0
        hasher.Write((const unsigned char*)CTL, sizeof(CTL));
142
0
        if (siz > sizeof(buffer)) siz = sizeof(buffer);
143
0
        hasher << siz;
144
0
        hasher.Write(buffer, siz);
145
0
    }
146
0
}
Unexecuted instantiation: randomenv.cpp:void (anonymous namespace)::AddSysctl<1, 14, 0>(CSHA512&)
Unexecuted instantiation: randomenv.cpp:void (anonymous namespace)::AddSysctl<6, 9>(CSHA512&)
Unexecuted instantiation: randomenv.cpp:void (anonymous namespace)::AddSysctl<2, 2>(CSHA512&)
Unexecuted instantiation: randomenv.cpp:void (anonymous namespace)::AddSysctl<2, 1>(CSHA512&)
Unexecuted instantiation: randomenv.cpp:void (anonymous namespace)::AddSysctl<6, 1>(CSHA512&)
Unexecuted instantiation: randomenv.cpp:void (anonymous namespace)::AddSysctl<6, 2>(CSHA512&)
Unexecuted instantiation: randomenv.cpp:void (anonymous namespace)::AddSysctl<6, 3>(CSHA512&)
Unexecuted instantiation: randomenv.cpp:void (anonymous namespace)::AddSysctl<6, 5>(CSHA512&)
Unexecuted instantiation: randomenv.cpp:void (anonymous namespace)::AddSysctl<6, 6>(CSHA512&)
Unexecuted instantiation: randomenv.cpp:void (anonymous namespace)::AddSysctl<6, 12>(CSHA512&)
Unexecuted instantiation: randomenv.cpp:void (anonymous namespace)::AddSysctl<6, 15>(CSHA512&)
Unexecuted instantiation: randomenv.cpp:void (anonymous namespace)::AddSysctl<6, 14>(CSHA512&)
Unexecuted instantiation: randomenv.cpp:void (anonymous namespace)::AddSysctl<6, 16>(CSHA512&)
Unexecuted instantiation: randomenv.cpp:void (anonymous namespace)::AddSysctl<1, 28>(CSHA512&)
Unexecuted instantiation: randomenv.cpp:void (anonymous namespace)::AddSysctl<1, 21>(CSHA512&)
Unexecuted instantiation: randomenv.cpp:void (anonymous namespace)::AddSysctl<1, 12>(CSHA512&)
Unexecuted instantiation: randomenv.cpp:void (anonymous namespace)::AddSysctl<1, 11>(CSHA512&)
Unexecuted instantiation: randomenv.cpp:void (anonymous namespace)::AddSysctl<1, 10>(CSHA512&)
Unexecuted instantiation: randomenv.cpp:void (anonymous namespace)::AddSysctl<1, 26>(CSHA512&)
Unexecuted instantiation: randomenv.cpp:void (anonymous namespace)::AddSysctl<1, 2>(CSHA512&)
Unexecuted instantiation: randomenv.cpp:void (anonymous namespace)::AddSysctl<1, 3>(CSHA512&)
Unexecuted instantiation: randomenv.cpp:void (anonymous namespace)::AddSysctl<1, 1>(CSHA512&)
Unexecuted instantiation: randomenv.cpp:void (anonymous namespace)::AddSysctl<1, 4>(CSHA512&)
147
#endif
148
149
#ifdef HAVE_GETCPUID
150
void inline AddCPUID(CSHA512& hasher, uint32_t leaf, uint32_t subleaf, uint32_t& ax, uint32_t& bx, uint32_t& cx, uint32_t& dx)
151
{
152
    GetCPUID(leaf, subleaf, ax, bx, cx, dx);
153
    hasher << leaf << subleaf << ax << bx << cx << dx;
154
}
155
156
void AddAllCPUID(CSHA512& hasher)
157
{
158
    uint32_t ax, bx, cx, dx;
159
    // Iterate over all standard leaves
160
    AddCPUID(hasher, 0, 0, ax, bx, cx, dx); // Returns max leaf in ax
161
    uint32_t max = ax;
162
    for (uint32_t leaf = 1; leaf <= max && leaf <= 0xFF; ++leaf) {
163
        uint32_t maxsub = 0;
164
        for (uint32_t subleaf = 0; subleaf <= 0xFF; ++subleaf) {
165
            AddCPUID(hasher, leaf, subleaf, ax, bx, cx, dx);
166
            // Iterate subleafs for leaf values 4, 7, 11, 13
167
            if (leaf == 4) {
168
                if ((ax & 0x1f) == 0) break;
169
            } else if (leaf == 7) {
170
                if (subleaf == 0) maxsub = ax;
171
                if (subleaf == maxsub) break;
172
            } else if (leaf == 11) {
173
                if ((cx & 0xff00) == 0) break;
174
            } else if (leaf == 13) {
175
                if (ax == 0 && bx == 0 && cx == 0 && dx == 0) break;
176
            } else {
177
                // For any other leaf, stop after subleaf 0.
178
                break;
179
            }
180
        }
181
    }
182
    // Iterate over all extended leaves
183
    AddCPUID(hasher, 0x80000000, 0, ax, bx, cx, dx); // Returns max extended leaf in ax
184
    uint32_t ext_max = ax;
185
    for (uint32_t leaf = 0x80000001; leaf <= ext_max && leaf <= 0x800000FF; ++leaf) {
186
        AddCPUID(hasher, leaf, 0, ax, bx, cx, dx);
187
    }
188
}
189
#endif
190
} // namespace
191
192
void RandAddDynamicEnv(CSHA512& hasher)
193
0
{
194
    // Various clocks
195
#ifdef WIN32
196
    FILETIME ftime;
197
    GetSystemTimeAsFileTime(&ftime);
198
    hasher << ftime;
199
#else
200
0
    struct timespec ts = {};
201
0
#    ifdef CLOCK_MONOTONIC
202
0
    clock_gettime(CLOCK_MONOTONIC, &ts);
203
0
    hasher << ts;
204
0
#    endif
205
0
#    ifdef CLOCK_REALTIME
206
0
    clock_gettime(CLOCK_REALTIME, &ts);
207
0
    hasher << ts;
208
0
#    endif
209
#    ifdef CLOCK_BOOTTIME
210
    clock_gettime(CLOCK_BOOTTIME, &ts);
211
    hasher << ts;
212
#    endif
213
    // gettimeofday is available on all UNIX systems, but only has microsecond precision.
214
0
    struct timeval tv = {};
215
0
    gettimeofday(&tv, nullptr);
216
0
    hasher << tv;
217
0
#endif
218
    // Probably redundant, but also use all the standard library clocks:
219
0
    hasher << std::chrono::system_clock::now().time_since_epoch().count();
220
0
    hasher << std::chrono::steady_clock::now().time_since_epoch().count();
221
0
    hasher << std::chrono::high_resolution_clock::now().time_since_epoch().count();
222
223
0
#ifndef WIN32
224
    // Current resource usage.
225
0
    struct rusage usage = {};
226
0
    if (getrusage(RUSAGE_SELF, &usage) == 0) hasher << usage;
227
0
#endif
228
229
#ifdef __linux__
230
    AddFile(hasher, "/proc/diskstats");
231
    AddFile(hasher, "/proc/vmstat");
232
    AddFile(hasher, "/proc/schedstat");
233
    AddFile(hasher, "/proc/zoneinfo");
234
    AddFile(hasher, "/proc/meminfo");
235
    AddFile(hasher, "/proc/softirqs");
236
    AddFile(hasher, "/proc/stat");
237
    AddFile(hasher, "/proc/self/schedstat");
238
    AddFile(hasher, "/proc/self/status");
239
#endif
240
241
0
#ifdef HAVE_SYSCTL
242
0
#  ifdef CTL_KERN
243
0
#    if defined(KERN_PROC) && defined(KERN_PROC_ALL)
244
0
    AddSysctl<CTL_KERN, KERN_PROC, KERN_PROC_ALL>(hasher);
245
0
#    endif
246
0
#  endif
247
0
#  ifdef CTL_HW
248
0
#    ifdef HW_DISKSTATS
249
0
    AddSysctl<CTL_HW, HW_DISKSTATS>(hasher);
250
0
#    endif
251
0
#  endif
252
0
#  ifdef CTL_VM
253
0
#    ifdef VM_LOADAVG
254
0
    AddSysctl<CTL_VM, VM_LOADAVG>(hasher);
255
0
#    endif
256
#    ifdef VM_TOTAL
257
    AddSysctl<CTL_VM, VM_TOTAL>(hasher);
258
#    endif
259
0
#    ifdef VM_METER
260
0
    AddSysctl<CTL_VM, VM_METER>(hasher);
261
0
#    endif
262
0
#  endif
263
0
#endif
264
265
    // Stack and heap location
266
0
    void* addr = malloc(4097);
267
0
    hasher << &addr << addr;
268
0
    free(addr);
269
0
}
270
271
void RandAddStaticEnv(CSHA512& hasher)
272
0
{
273
    // Some compile-time static properties
274
0
    hasher << (CHAR_MIN < 0) << sizeof(void*) << sizeof(long) << sizeof(int);
275
0
#if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
276
0
    hasher << __GNUC__ << __GNUC_MINOR__ << __GNUC_PATCHLEVEL__;
277
0
#endif
278
#ifdef _MSC_VER
279
    hasher << _MSC_VER;
280
#endif
281
0
    hasher << __cplusplus;
282
0
#ifdef _XOPEN_VERSION
283
0
    hasher << _XOPEN_VERSION;
284
0
#endif
285
0
#ifdef __VERSION__
286
0
    const char* COMPILER_VERSION = __VERSION__;
287
0
    hasher.Write((const unsigned char*)COMPILER_VERSION, strlen(COMPILER_VERSION) + 1);
288
0
#endif
289
290
    // Bitcoin client version
291
0
    hasher << CLIENT_VERSION;
292
293
#if defined(HAVE_STRONG_GETAUXVAL)
294
    // Information available through getauxval()
295
#  ifdef AT_HWCAP
296
    hasher << getauxval(AT_HWCAP);
297
#  endif
298
#  ifdef AT_HWCAP2
299
    hasher << getauxval(AT_HWCAP2);
300
#  endif
301
#  ifdef AT_RANDOM
302
    const unsigned char* random_aux = (const unsigned char*)getauxval(AT_RANDOM);
303
    if (random_aux) hasher.Write(random_aux, 16);
304
#  endif
305
#  ifdef AT_PLATFORM
306
    const char* platform_str = (const char*)getauxval(AT_PLATFORM);
307
    if (platform_str) hasher.Write((const unsigned char*)platform_str, strlen(platform_str) + 1);
308
#  endif
309
#  ifdef AT_EXECFN
310
    const char* exec_str = (const char*)getauxval(AT_EXECFN);
311
    if (exec_str) hasher.Write((const unsigned char*)exec_str, strlen(exec_str) + 1);
312
#  endif
313
#endif // HAVE_STRONG_GETAUXVAL
314
315
#ifdef HAVE_GETCPUID
316
    AddAllCPUID(hasher);
317
#endif
318
319
    // Memory locations
320
0
    hasher << &hasher << &RandAddStaticEnv << &malloc << &errno << &environ;
321
322
    // Hostname
323
#ifdef WIN32
324
    constexpr DWORD max_size = MAX_COMPUTERNAME_LENGTH + 1;
325
    char hname[max_size];
326
    DWORD size = max_size;
327
    if (GetComputerNameA(hname, &size) != 0) {
328
        hasher.Write(UCharCast(hname), size);
329
    }
330
#else
331
0
    char hname[256];
332
0
    if (gethostname(hname, 256) == 0) {
333
0
        hasher.Write((const unsigned char*)hname, strnlen(hname, 256));
334
0
    }
335
0
#endif
336
337
0
#ifdef HAVE_IFADDRS
338
    // Network interfaces
339
0
    struct ifaddrs *ifad = nullptr;
340
0
    getifaddrs(&ifad);
341
0
    struct ifaddrs *ifit = ifad;
342
0
    while (ifit != nullptr) {
343
0
        hasher.Write((const unsigned char*)&ifit, sizeof(ifit));
344
0
        hasher.Write((const unsigned char*)ifit->ifa_name, strlen(ifit->ifa_name) + 1);
345
0
        hasher.Write((const unsigned char*)&ifit->ifa_flags, sizeof(ifit->ifa_flags));
346
0
        AddSockaddr(hasher, ifit->ifa_addr);
347
0
        AddSockaddr(hasher, ifit->ifa_netmask);
348
0
        AddSockaddr(hasher, ifit->ifa_dstaddr);
349
0
        ifit = ifit->ifa_next;
350
0
    }
351
0
    freeifaddrs(ifad);
352
0
#endif
353
354
0
#ifndef WIN32
355
    // UNIX kernel information
356
0
    struct utsname name;
357
0
    if (uname(&name) != -1) {
358
0
        hasher.Write((const unsigned char*)&name.sysname, strlen(name.sysname) + 1);
359
0
        hasher.Write((const unsigned char*)&name.nodename, strlen(name.nodename) + 1);
360
0
        hasher.Write((const unsigned char*)&name.release, strlen(name.release) + 1);
361
0
        hasher.Write((const unsigned char*)&name.version, strlen(name.version) + 1);
362
0
        hasher.Write((const unsigned char*)&name.machine, strlen(name.machine) + 1);
363
0
    }
364
365
    /* Path and filesystem provided data */
366
0
    AddPath(hasher, "/");
367
0
    AddPath(hasher, ".");
368
0
    AddPath(hasher, "/tmp");
369
0
    AddPath(hasher, "/home");
370
0
    AddPath(hasher, "/proc");
371
#ifdef __linux__
372
    AddFile(hasher, "/proc/cmdline");
373
    AddFile(hasher, "/proc/cpuinfo");
374
    AddFile(hasher, "/proc/version");
375
#endif
376
0
    AddFile(hasher, "/etc/passwd");
377
0
    AddFile(hasher, "/etc/group");
378
0
    AddFile(hasher, "/etc/hosts");
379
0
    AddFile(hasher, "/etc/resolv.conf");
380
0
    AddFile(hasher, "/etc/timezone");
381
0
    AddFile(hasher, "/etc/localtime");
382
0
#endif
383
384
    // For MacOS/BSDs, gather data through sysctl instead of /proc. Not all of these
385
    // will exist on every system.
386
0
#ifdef HAVE_SYSCTL
387
0
#  ifdef CTL_HW
388
0
#    ifdef HW_MACHINE
389
0
    AddSysctl<CTL_HW, HW_MACHINE>(hasher);
390
0
#    endif
391
0
#    ifdef HW_MODEL
392
0
    AddSysctl<CTL_HW, HW_MODEL>(hasher);
393
0
#    endif
394
0
#    ifdef HW_NCPU
395
0
    AddSysctl<CTL_HW, HW_NCPU>(hasher);
396
0
#    endif
397
0
#    ifdef HW_PHYSMEM
398
0
    AddSysctl<CTL_HW, HW_PHYSMEM>(hasher);
399
0
#    endif
400
0
#    ifdef HW_USERMEM
401
0
    AddSysctl<CTL_HW, HW_USERMEM>(hasher);
402
0
#    endif
403
0
#    ifdef HW_MACHINE_ARCH
404
0
    AddSysctl<CTL_HW, HW_MACHINE_ARCH>(hasher);
405
0
#    endif
406
#    ifdef HW_REALMEM
407
    AddSysctl<CTL_HW, HW_REALMEM>(hasher);
408
#    endif
409
0
#    ifdef HW_CPU_FREQ
410
0
    AddSysctl<CTL_HW, HW_CPU_FREQ>(hasher);
411
0
#    endif
412
0
#    ifdef HW_BUS_FREQ
413
0
    AddSysctl<CTL_HW, HW_BUS_FREQ>(hasher);
414
0
#    endif
415
0
#    ifdef HW_CACHELINE
416
0
    AddSysctl<CTL_HW, HW_CACHELINE>(hasher);
417
0
#    endif
418
0
#  endif
419
0
#  ifdef CTL_KERN
420
0
#    ifdef KERN_BOOTFILE
421
0
     AddSysctl<CTL_KERN, KERN_BOOTFILE>(hasher);
422
0
#    endif
423
0
#    ifdef KERN_BOOTTIME
424
0
     AddSysctl<CTL_KERN, KERN_BOOTTIME>(hasher);
425
0
#    endif
426
0
#    ifdef KERN_CLOCKRATE
427
0
     AddSysctl<CTL_KERN, KERN_CLOCKRATE>(hasher);
428
0
#    endif
429
0
#    ifdef KERN_HOSTID
430
0
     AddSysctl<CTL_KERN, KERN_HOSTID>(hasher);
431
0
#    endif
432
#    ifdef KERN_HOSTUUID
433
     AddSysctl<CTL_KERN, KERN_HOSTUUID>(hasher);
434
#    endif
435
0
#    ifdef KERN_HOSTNAME
436
0
     AddSysctl<CTL_KERN, KERN_HOSTNAME>(hasher);
437
0
#    endif
438
0
#    ifdef KERN_OSRELDATE
439
0
     AddSysctl<CTL_KERN, KERN_OSRELDATE>(hasher);
440
0
#    endif
441
0
#    ifdef KERN_OSRELEASE
442
0
     AddSysctl<CTL_KERN, KERN_OSRELEASE>(hasher);
443
0
#    endif
444
0
#    ifdef KERN_OSREV
445
0
     AddSysctl<CTL_KERN, KERN_OSREV>(hasher);
446
0
#    endif
447
0
#    ifdef KERN_OSTYPE
448
0
     AddSysctl<CTL_KERN, KERN_OSTYPE>(hasher);
449
0
#    endif
450
0
#    ifdef KERN_POSIX1
451
0
     AddSysctl<CTL_KERN, KERN_OSREV>(hasher);
452
0
#    endif
453
0
#    ifdef KERN_VERSION
454
0
     AddSysctl<CTL_KERN, KERN_VERSION>(hasher);
455
0
#    endif
456
0
#  endif
457
0
#endif
458
459
    // Env variables
460
0
    if (environ) {
461
0
        for (size_t i = 0; environ[i]; ++i) {
462
0
            hasher.Write((const unsigned char*)environ[i], strlen(environ[i]));
463
0
        }
464
0
    }
465
466
    // Process, thread, user, session, group, ... ids.
467
#ifdef WIN32
468
    hasher << GetCurrentProcessId() << GetCurrentThreadId();
469
#else
470
0
    hasher << getpid() << getppid() << getsid(0) << getpgid(0) << getuid() << geteuid() << getgid() << getegid();
471
0
#endif
472
0
    hasher << std::this_thread::get_id();
473
0
}