Coverage Report

Created: 2022-07-22 12:05

/libfido2/fuzz/wrap.c
Line
Count
Source
1
/*
2
 * Copyright (c) 2019-2022 Yubico AB. All rights reserved.
3
 * Use of this source code is governed by a BSD-style
4
 * license that can be found in the LICENSE file.
5
 */
6
7
#include <sys/types.h>
8
#include <sys/random.h>
9
#include <sys/socket.h>
10
11
#include <openssl/bn.h>
12
#include <openssl/evp.h>
13
#include <openssl/sha.h>
14
15
#include <cbor.h>
16
#include <stdbool.h>
17
#include <stdint.h>
18
#include <stdio.h>
19
#include <stdlib.h>
20
#include <zlib.h>
21
22
#include "mutator_aux.h"
23
24
extern int prng_up;
25
26
int fuzz_save_corpus;
27
28
/*
29
 * Build wrappers around functions of interest, and have them fail
30
 * in a pseudo-random manner. A uniform probability of 0.25% (1/400)
31
 * allows for a depth of log(0.5)/log(399/400) > 276 operations
32
 * before simulated errors become statistically more likely. 
33
 */
34
35
#define WRAP(type, name, args, retval, param, prob)     \
36
extern type __wrap_##name args;                         \
37
extern type __real_##name args;                         \
38
7.49M
type __wrap_##name args {                               \
39
7.49M
        if (prng_up && uniform_random(400) < (prob)) {       \
40
20.0k
                return (retval);                        \
41
20.0k
        }                                                \
42
7.49M
                                                        \
43
7.49M
        return (__real_##name param);                       \
44
7.49M
}
__wrap_malloc
Line
Count
Source
38
384k
type __wrap_##name args {                               \
39
384k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
1.28k
                return (retval);                        \
41
1.28k
        }                                                \
42
384k
                                                        \
43
384k
        return (__real_##name param);                       \
44
384k
}
__wrap_calloc
Line
Count
Source
38
5.23M
type __wrap_##name args {                               \
39
5.23M
        if (prng_up && uniform_random(400) < (prob)) {       \
40
13.4k
                return (retval);                        \
41
13.4k
        }                                                \
42
5.23M
                                                        \
43
5.23M
        return (__real_##name param);                       \
44
5.23M
}
__wrap_realloc
Line
Count
Source
38
362
type __wrap_##name args {                               \
39
362
        if (prng_up && uniform_random(400) < (prob)) {       \
40
1
                return (retval);                        \
41
1
        }                                                \
42
362
                                                        \
43
362
        return (__real_##name param);                       \
44
362
}
__wrap_strdup
Line
Count
Source
38
213k
type __wrap_##name args {                               \
39
213k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
694
                return (retval);                        \
41
694
        }                                                \
42
213k
                                                        \
43
213k
        return (__real_##name param);                       \
44
213k
}
__wrap_getrandom
Line
Count
Source
38
493k
type __wrap_##name args {                               \
39
493k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
1.27k
                return (retval);                        \
41
1.27k
        }                                                \
42
493k
                                                        \
43
493k
        return (__real_##name param);                       \
44
493k
}
__wrap_EVP_Cipher
Line
Count
Source
38
4.18k
type __wrap_##name args {                               \
39
4.18k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
20
                return (retval);                        \
41
20
        }                                                \
42
4.18k
                                                        \
43
4.18k
        return (__real_##name param);                       \
44
4.18k
}
__wrap_EVP_CIPHER_CTX_ctrl
Line
Count
Source
38
762
type __wrap_##name args {                               \
39
762
        if (prng_up && uniform_random(400) < (prob)) {       \
40
6
                return (retval);                        \
41
6
        }                                                \
42
762
                                                        \
43
762
        return (__real_##name param);                       \
44
762
}
__wrap_EVP_CIPHER_CTX_new
Line
Count
Source
38
2.72k
type __wrap_##name args {                               \
39
2.72k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
17
                return (retval);                        \
41
17
        }                                                \
42
2.72k
                                                        \
43
2.72k
        return (__real_##name param);                       \
44
2.72k
}
__wrap_EVP_CipherInit
Line
Count
Source
38
2.69k
type __wrap_##name args {                               \
39
2.69k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
14
                return (retval);                        \
41
14
        }                                                \
42
2.69k
                                                        \
43
2.69k
        return (__real_##name param);                       \
44
2.69k
}
Unexecuted instantiation: __wrap_EVP_PKEY_get0_RSA
__wrap_EVP_PKEY_get0_EC_KEY
Line
Count
Source
38
3.65k
type __wrap_##name args {                               \
39
3.65k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
16
                return (retval);                        \
41
16
        }                                                \
42
3.65k
                                                        \
43
3.65k
        return (__real_##name param);                       \
44
3.65k
}
__wrap_EVP_PKEY_get_raw_public_key
Line
Count
Source
38
1.08k
type __wrap_##name args {                               \
39
1.08k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
10
                return (retval);                        \
41
10
        }                                                \
42
1.08k
                                                        \
43
1.08k
        return (__real_##name param);                       \
44
1.08k
}
__wrap_EVP_MD_CTX_new
Line
Count
Source
38
432
type __wrap_##name args {                               \
39
432
        if (prng_up && uniform_random(400) < (prob)) {       \
40
10
                return (retval);                        \
41
10
        }                                                \
42
432
                                                        \
43
432
        return (__real_##name param);                       \
44
432
}
__wrap_EVP_DigestVerifyInit
Line
Count
Source
38
95
type __wrap_##name args {                               \
39
95
        if (prng_up && uniform_random(400) < (prob)) {       \
40
2
                return (retval);                        \
41
2
        }                                                \
42
95
                                                        \
43
95
        return (__real_##name param);                       \
44
95
}
__wrap_EVP_DigestInit_ex
Line
Count
Source
38
327
type __wrap_##name args {                               \
39
327
        if (prng_up && uniform_random(400) < (prob)) {       \
40
6
                return (retval);                        \
41
6
        }                                                \
42
327
                                                        \
43
327
        return (__real_##name param);                       \
44
327
}
__wrap_EVP_DigestUpdate
Line
Count
Source
38
831
type __wrap_##name args {                               \
39
831
        if (prng_up && uniform_random(400) < (prob)) {       \
40
25
                return (retval);                        \
41
25
        }                                                \
42
831
                                                        \
43
831
        return (__real_##name param);                       \
44
831
}
__wrap_EVP_DigestFinal_ex
Line
Count
Source
38
296
type __wrap_##name args {                               \
39
296
        if (prng_up && uniform_random(400) < (prob)) {       \
40
9
                return (retval);                        \
41
9
        }                                                \
42
296
                                                        \
43
296
        return (__real_##name param);                       \
44
296
}
__wrap_BN_bin2bn
Line
Count
Source
38
11.6k
type __wrap_##name args {                               \
39
11.6k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
134
                return (retval);                        \
41
134
        }                                                \
42
11.6k
                                                        \
43
11.6k
        return (__real_##name param);                       \
44
11.6k
}
__wrap_BN_bn2bin
Line
Count
Source
38
10.7k
type __wrap_##name args {                               \
39
10.7k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
76
                return (retval);                        \
41
76
        }                                                \
42
10.7k
                                                        \
43
10.7k
        return (__real_##name param);                       \
44
10.7k
}
__wrap_BN_CTX_get
Line
Count
Source
38
13.8k
type __wrap_##name args {                               \
39
13.8k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
95
                return (retval);                        \
41
95
        }                                                \
42
13.8k
                                                        \
43
13.8k
        return (__real_##name param);                       \
44
13.8k
}
__wrap_BN_CTX_new
Line
Count
Source
38
7.75k
type __wrap_##name args {                               \
39
7.75k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
61
                return (retval);                        \
41
61
        }                                                \
42
7.75k
                                                        \
43
7.75k
        return (__real_##name param);                       \
44
7.75k
}
__wrap_BN_new
Line
Count
Source
38
1.49k
type __wrap_##name args {                               \
39
1.49k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
17
                return (retval);                        \
41
17
        }                                                \
42
1.49k
                                                        \
43
1.49k
        return (__real_##name param);                       \
44
1.49k
}
__wrap_RSA_new
Line
Count
Source
38
705
type __wrap_##name args {                               \
39
705
        if (prng_up && uniform_random(400) < (prob)) {       \
40
7
                return (retval);                        \
41
7
        }                                                \
42
705
                                                        \
43
705
        return (__real_##name param);                       \
44
705
}
__wrap_RSA_set0_key
Line
Count
Source
38
698
type __wrap_##name args {                               \
39
698
        if (prng_up && uniform_random(400) < (prob)) {       \
40
7
                return (retval);                        \
41
7
        }                                                \
42
698
                                                        \
43
698
        return (__real_##name param);                       \
44
698
}
__wrap_RSA_pkey_ctx_ctrl
Line
Count
Source
38
64
type __wrap_##name args {                               \
39
64
        if (prng_up && uniform_random(400) < (prob)) {       \
40
3
                return (retval);                        \
41
3
        }                                                \
42
64
                                                        \
43
64
        return (__real_##name param);                       \
44
64
}
__wrap_EC_KEY_new_by_curve_name
Line
Count
Source
38
7.58k
type __wrap_##name args {                               \
39
7.58k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
48
                return (retval);                        \
41
48
        }                                                \
42
7.58k
                                                        \
43
7.58k
        return (__real_##name param);                       \
44
7.58k
}
__wrap_EC_KEY_get0_group
Line
Count
Source
38
6.04k
type __wrap_##name args {                               \
39
6.04k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
40
                return (retval);                        \
41
40
        }                                                \
42
6.04k
                                                        \
43
6.04k
        return (__real_##name param);                       \
44
6.04k
}
__wrap_EC_KEY_get0_private_key
Line
Count
Source
38
3.64k
type __wrap_##name args {                               \
39
3.64k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
18
                return (retval);                        \
41
18
        }                                                \
42
3.64k
                                                        \
43
3.64k
        return (__real_##name param);                       \
44
3.64k
}
__wrap_EC_POINT_new
Line
Count
Source
38
6.00k
type __wrap_##name args {                               \
39
6.00k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
39
                return (retval);                        \
41
39
        }                                                \
42
6.00k
                                                        \
43
6.00k
        return (__real_##name param);                       \
44
6.00k
}
__wrap_EC_POINT_get_affine_coordinates_GFp
Line
Count
Source
38
3.50k
type __wrap_##name args {                               \
39
3.50k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
20
                return (retval);                        \
41
20
        }                                                \
42
3.50k
                                                        \
43
3.50k
        return (__real_##name param);                       \
44
3.50k
}
__wrap_EVP_PKEY_new
Line
Count
Source
38
3.45k
type __wrap_##name args {                               \
39
3.45k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
18
                return (retval);                        \
41
18
        }                                                \
42
3.45k
                                                        \
43
3.45k
        return (__real_##name param);                       \
44
3.45k
}
__wrap_EVP_PKEY_assign
Line
Count
Source
38
3.44k
type __wrap_##name args {                               \
39
3.44k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
21
                return (retval);                        \
41
21
        }                                                \
42
3.44k
                                                        \
43
3.44k
        return (__real_##name param);                       \
44
3.44k
}
__wrap_EVP_PKEY_keygen_init
Line
Count
Source
38
3.69k
type __wrap_##name args {                               \
39
3.69k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
14
                return (retval);                        \
41
14
        }                                                \
42
3.69k
                                                        \
43
3.69k
        return (__real_##name param);                       \
44
3.69k
}
__wrap_EVP_PKEY_keygen
Line
Count
Source
38
3.68k
type __wrap_##name args {                               \
39
3.68k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
21
                return (retval);                        \
41
21
        }                                                \
42
3.68k
                                                        \
43
3.68k
        return (__real_##name param);                       \
44
3.68k
}
__wrap_EVP_PKEY_paramgen_init
Line
Count
Source
38
3.77k
type __wrap_##name args {                               \
39
3.77k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
19
                return (retval);                        \
41
19
        }                                                \
42
3.77k
                                                        \
43
3.77k
        return (__real_##name param);                       \
44
3.77k
}
__wrap_EVP_PKEY_paramgen
Line
Count
Source
38
3.73k
type __wrap_##name args {                               \
39
3.73k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
23
                return (retval);                        \
41
23
        }                                                \
42
3.73k
                                                        \
43
3.73k
        return (__real_##name param);                       \
44
3.73k
}
__wrap_EVP_PKEY_new_raw_public_key
Line
Count
Source
38
715
type __wrap_##name args {                               \
39
715
        if (prng_up && uniform_random(400) < (prob)) {       \
40
10
                return (retval);                        \
41
10
        }                                                \
42
715
                                                        \
43
715
        return (__real_##name param);                       \
44
715
}
__wrap_EVP_PKEY_CTX_new
Line
Count
Source
38
5.34k
type __wrap_##name args {                               \
39
5.34k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
32
                return (retval);                        \
41
32
        }                                                \
42
5.34k
                                                        \
43
5.34k
        return (__real_##name param);                       \
44
5.34k
}
__wrap_EVP_PKEY_CTX_new_id
Line
Count
Source
38
4.66k
type __wrap_##name args {                               \
39
4.66k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
32
                return (retval);                        \
41
32
        }                                                \
42
4.66k
                                                        \
43
4.66k
        return (__real_##name param);                       \
44
4.66k
}
__wrap_EVP_PKEY_derive
Line
Count
Source
38
3.73k
type __wrap_##name args {                               \
39
3.73k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
24
                return (retval);                        \
41
24
        }                                                \
42
3.73k
                                                        \
43
3.73k
        return (__real_##name param);                       \
44
3.73k
}
__wrap_EVP_PKEY_derive_init
Line
Count
Source
38
2.33k
type __wrap_##name args {                               \
39
2.33k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
16
                return (retval);                        \
41
16
        }                                                \
42
2.33k
                                                        \
43
2.33k
        return (__real_##name param);                       \
44
2.33k
}
__wrap_EVP_PKEY_derive_set_peer
Line
Count
Source
38
1.47k
type __wrap_##name args {                               \
39
1.47k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
6
                return (retval);                        \
41
6
        }                                                \
42
1.47k
                                                        \
43
1.47k
        return (__real_##name param);                       \
44
1.47k
}
__wrap_EVP_PKEY_verify_init
Line
Count
Source
38
146
type __wrap_##name args {                               \
39
146
        if (prng_up && uniform_random(400) < (prob)) {       \
40
7
                return (retval);                        \
41
7
        }                                                \
42
146
                                                        \
43
146
        return (__real_##name param);                       \
44
146
}
__wrap_EVP_PKEY_CTX_ctrl
Line
Count
Source
38
7.17k
type __wrap_##name args {                               \
39
7.17k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
59
                return (retval);                        \
41
59
        }                                                \
42
7.17k
                                                        \
43
7.17k
        return (__real_##name param);                       \
44
7.17k
}
__wrap_EVP_sha1
Line
Count
Source
38
37
type __wrap_##name args {                               \
39
37
        if (prng_up && uniform_random(400) < (prob)) {       \
40
2
                return (retval);                        \
41
2
        }                                                \
42
37
                                                        \
43
37
        return (__real_##name param);                       \
44
37
}
__wrap_EVP_sha256
Line
Count
Source
38
1.99k
type __wrap_##name args {                               \
39
1.99k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
24
                return (retval);                        \
41
24
        }                                                \
42
1.99k
                                                        \
43
1.99k
        return (__real_##name param);                       \
44
1.99k
}
__wrap_EVP_aes_256_cbc
Line
Count
Source
38
1.93k
type __wrap_##name args {                               \
39
1.93k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
11
                return (retval);                        \
41
11
        }                                                \
42
1.93k
                                                        \
43
1.93k
        return (__real_##name param);                       \
44
1.93k
}
__wrap_EVP_aes_256_gcm
Line
Count
Source
38
776
type __wrap_##name args {                               \
39
776
        if (prng_up && uniform_random(400) < (prob)) {       \
40
4
                return (retval);                        \
41
4
        }                                                \
42
776
                                                        \
43
776
        return (__real_##name param);                       \
44
776
}
__wrap_HMAC
Line
Count
Source
38
765
type __wrap_##name args {                               \
39
765
        if (prng_up && uniform_random(400) < (prob)) {       \
40
7
                return (retval);                        \
41
7
        }                                                \
42
765
                                                        \
43
765
        return (__real_##name param);                       \
44
765
}
__wrap_HMAC_CTX_new
Line
Count
Source
38
30
type __wrap_##name args {                               \
39
30
        if (prng_up && uniform_random(400) < (prob)) {       \
40
1
                return (retval);                        \
41
1
        }                                                \
42
30
                                                        \
43
30
        return (__real_##name param);                       \
44
30
}
__wrap_HMAC_Init_ex
Line
Count
Source
38
28
type __wrap_##name args {                               \
39
28
        if (prng_up && uniform_random(400) < (prob)) {       \
40
1
                return (retval);                        \
41
1
        }                                                \
42
28
                                                        \
43
28
        return (__real_##name param);                       \
44
28
}
__wrap_HMAC_Update
Line
Count
Source
38
53
type __wrap_##name args {                               \
39
53
        if (prng_up && uniform_random(400) < (prob)) {       \
40
2
                return (retval);                        \
41
2
        }                                                \
42
53
                                                        \
43
53
        return (__real_##name param);                       \
44
53
}
__wrap_HMAC_Final
Line
Count
Source
38
25
type __wrap_##name args {                               \
39
25
        if (prng_up && uniform_random(400) < (prob)) {       \
40
1
                return (retval);                        \
41
1
        }                                                \
42
25
                                                        \
43
25
        return (__real_##name param);                       \
44
25
}
__wrap_SHA1
Line
Count
Source
38
13
type __wrap_##name args {                               \
39
13
        if (prng_up && uniform_random(400) < (prob)) {       \
40
1
                return (retval);                        \
41
1
        }                                                \
42
13
                                                        \
43
13
        return (__real_##name param);                       \
44
13
}
__wrap_SHA256
Line
Count
Source
38
8.15k
type __wrap_##name args {                               \
39
8.15k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
49
                return (retval);                        \
41
49
        }                                                \
42
8.15k
                                                        \
43
8.15k
        return (__real_##name param);                       \
44
8.15k
}
__wrap_cbor_build_string
Line
Count
Source
38
125k
type __wrap_##name args {                               \
39
125k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
94
                return (retval);                        \
41
94
        }                                                \
42
125k
                                                        \
43
125k
        return (__real_##name param);                       \
44
125k
}
__wrap_cbor_build_bytestring
Line
Count
Source
38
40.4k
type __wrap_##name args {                               \
39
40.4k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
69
                return (retval);                        \
41
69
        }                                                \
42
40.4k
                                                        \
43
40.4k
        return (__real_##name param);                       \
44
40.4k
}
__wrap_cbor_build_bool
Line
Count
Source
38
2.10k
type __wrap_##name args {                               \
39
2.10k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
7
                return (retval);                        \
41
7
        }                                                \
42
2.10k
                                                        \
43
2.10k
        return (__real_##name param);                       \
44
2.10k
}
__wrap_cbor_build_negint8
Line
Count
Source
38
5.43k
type __wrap_##name args {                               \
39
5.43k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
33
                return (retval);                        \
41
33
        }                                                \
42
5.43k
                                                        \
43
5.43k
        return (__real_##name param);                       \
44
5.43k
}
__wrap_cbor_build_negint16
Line
Count
Source
38
210
type __wrap_##name args {                               \
39
210
        if (prng_up && uniform_random(400) < (prob)) {       \
40
1
                return (retval);                        \
41
1
        }                                                \
42
210
                                                        \
43
210
        return (__real_##name param);                       \
44
210
}
__wrap_cbor_load
Line
Count
Source
38
14.5k
type __wrap_##name args {                               \
39
14.5k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
69
                return (retval);                        \
41
69
        }                                                \
42
14.5k
                                                        \
43
14.5k
        return (__real_##name param);                       \
44
14.5k
}
__wrap_cbor_build_uint8
Line
Count
Source
38
49.8k
type __wrap_##name args {                               \
39
49.8k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
226
                return (retval);                        \
41
226
        }                                                \
42
49.8k
                                                        \
43
49.8k
        return (__real_##name param);                       \
44
49.8k
}
__wrap_cbor_build_uint16
Line
Count
Source
38
613
type __wrap_##name args {                               \
39
613
        if (prng_up && uniform_random(400) < (prob)) {       \
40
4
                return (retval);                        \
41
4
        }                                                \
42
613
                                                        \
43
613
        return (__real_##name param);                       \
44
613
}
__wrap_cbor_build_uint32
Line
Count
Source
38
180
type __wrap_##name args {                               \
39
180
        if (prng_up && uniform_random(400) < (prob)) {       \
40
2
                return (retval);                        \
41
2
        }                                                \
42
180
                                                        \
43
180
        return (__real_##name param);                       \
44
180
}
Unexecuted instantiation: __wrap_cbor_build_uint64
__wrap_cbor_map_handle
Line
Count
Source
38
25.5k
type __wrap_##name args {                               \
39
25.5k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
83
                return (retval);                        \
41
83
        }                                                \
42
25.5k
                                                        \
43
25.5k
        return (__real_##name param);                       \
44
25.5k
}
__wrap_cbor_array_handle
Line
Count
Source
38
16.3k
type __wrap_##name args {                               \
39
16.3k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
30
                return (retval);                        \
41
30
        }                                                \
42
16.3k
                                                        \
43
16.3k
        return (__real_##name param);                       \
44
16.3k
}
__wrap_cbor_array_push
Line
Count
Source
38
48.8k
type __wrap_##name args {                               \
39
48.8k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
53
                return (retval);                        \
41
53
        }                                                \
42
48.8k
                                                        \
43
48.8k
        return (__real_##name param);                       \
44
48.8k
}
__wrap_cbor_map_add
Line
Count
Source
38
104k
type __wrap_##name args {                               \
39
104k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
162
                return (retval);                        \
41
162
        }                                                \
42
104k
                                                        \
43
104k
        return (__real_##name param);                       \
44
104k
}
__wrap_cbor_new_definite_map
Line
Count
Source
38
49.1k
type __wrap_##name args {                               \
39
49.1k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
63
                return (retval);                        \
41
63
        }                                                \
42
49.1k
                                                        \
43
49.1k
        return (__real_##name param);                       \
44
49.1k
}
__wrap_cbor_new_definite_array
Line
Count
Source
38
2.46k
type __wrap_##name args {                               \
39
2.46k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
8
                return (retval);                        \
41
8
        }                                                \
42
2.46k
                                                        \
43
2.46k
        return (__real_##name param);                       \
44
2.46k
}
__wrap_cbor_new_definite_bytestring
Line
Count
Source
38
63
type __wrap_##name args {                               \
39
63
        if (prng_up && uniform_random(400) < (prob)) {       \
40
1
                return (retval);                        \
41
1
        }                                                \
42
63
                                                        \
43
63
        return (__real_##name param);                       \
44
63
}
__wrap_cbor_serialize_alloc
Line
Count
Source
38
13.2k
type __wrap_##name args {                               \
39
13.2k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
71
                return (retval);                        \
41
71
        }                                                \
42
13.2k
                                                        \
43
13.2k
        return (__real_##name param);                       \
44
13.2k
}
__wrap_fido_tx
Line
Count
Source
38
66.8k
type __wrap_##name args {                               \
39
66.8k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
246
                return (retval);                        \
41
246
        }                                                \
42
66.8k
                                                        \
43
66.8k
        return (__real_##name param);                       \
44
66.8k
}
__wrap_bind
Line
Count
Source
38
448k
type __wrap_##name args {                               \
39
448k
        if (prng_up && uniform_random(400) < (prob)) {       \
40
1.05k
                return (retval);                        \
41
1.05k
        }                                                \
42
448k
                                                        \
43
448k
        return (__real_##name param);                       \
44
448k
}
__wrap_deflateInit2_
Line
Count
Source
38
481
type __wrap_##name args {                               \
39
481
        if (prng_up && uniform_random(400) < (prob)) {       \
40
1
                return (retval);                        \
41
1
        }                                                \
42
481
                                                        \
43
481
        return (__real_##name param);                       \
44
481
}
45
46
WRAP(void *,
47
        malloc,
48
        (size_t size),
49
        NULL,
50
        (size),
51
        1
52
)
53
54
WRAP(void *,
55
        calloc,
56
        (size_t nmemb, size_t size),
57
        NULL,
58
        (nmemb, size),
59
        1
60
)
61
62
WRAP(void *,
63
        realloc,
64
        (void *ptr, size_t size),
65
        NULL,
66
        (ptr, size),
67
        1
68
)
69
70
WRAP(char *,
71
        strdup,
72
        (const char *s),
73
        NULL,
74
        (s),
75
        1
76
)
77
78
WRAP(ssize_t,
79
        getrandom,
80
        (void *buf, size_t buflen, unsigned int flags),
81
        -1,
82
        (buf, buflen, flags),
83
        1
84
)
85
86
WRAP(int,
87
        EVP_Cipher,
88
        (EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in,
89
            unsigned int inl),
90
        -1,
91
        (ctx, out, in, inl),
92
        1
93
)
94
95
WRAP(int,
96
        EVP_CIPHER_CTX_ctrl,
97
        (EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr),
98
        0,
99
        (ctx, type, arg, ptr),
100
        1
101
)
102
103
WRAP(EVP_CIPHER_CTX *,
104
        EVP_CIPHER_CTX_new,
105
        (void),
106
        NULL,
107
        (),
108
        1
109
)
110
111
WRAP(int,
112
        EVP_CipherInit,
113
        (EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
114
            const unsigned char *key, const unsigned char *iv, int enc),
115
        0,
116
        (ctx, cipher, key, iv, enc),
117
        1
118
)
119
120
WRAP(RSA *,
121
        EVP_PKEY_get0_RSA,
122
        (EVP_PKEY *pkey),
123
        NULL,
124
        (pkey),
125
        1
126
)
127
128
WRAP(EC_KEY *,
129
        EVP_PKEY_get0_EC_KEY,
130
        (EVP_PKEY *pkey),
131
        NULL,
132
        (pkey),
133
        1
134
)
135
136
WRAP(int,
137
        EVP_PKEY_get_raw_public_key,
138
        (const EVP_PKEY *pkey, unsigned char *pub, size_t *len),
139
        0,
140
        (pkey, pub, len),
141
        1
142
)
143
144
WRAP(EVP_MD_CTX *,
145
        EVP_MD_CTX_new,
146
        (void),
147
        NULL,
148
        (),
149
        1
150
)
151
152
WRAP(int,
153
        EVP_DigestVerifyInit,
154
        (EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, const EVP_MD *type, ENGINE *e,
155
            EVP_PKEY *pkey),
156
        0,
157
        (ctx, pctx, type, e, pkey),
158
        1
159
)
160
161
WRAP(int,
162
        EVP_DigestInit_ex,
163
        (EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl),
164
        0,
165
        (ctx, type, impl),
166
        1
167
)
168
169
WRAP(int,
170
        EVP_DigestUpdate,
171
        (EVP_MD_CTX *ctx, const void *data, size_t count),
172
        0,
173
        (ctx, data, count),
174
        1
175
)
176
177
WRAP(int,
178
        EVP_DigestFinal_ex,
179
        (EVP_MD_CTX *ctx, unsigned char *md, unsigned int *isize),
180
        0,
181
        (ctx, md, isize),
182
        1
183
)
184
185
WRAP(BIGNUM *,
186
        BN_bin2bn,
187
        (const unsigned char *s, int len, BIGNUM *ret),
188
        NULL,
189
        (s, len, ret),
190
        1
191
)
192
193
WRAP(int,
194
        BN_bn2bin,
195
        (const BIGNUM *a, unsigned char *to),
196
        -1,
197
        (a, to),
198
        1
199
)
200
201
WRAP(BIGNUM *,
202
        BN_CTX_get,
203
        (BN_CTX *ctx),
204
        NULL,
205
        (ctx),
206
        1
207
)
208
209
WRAP(BN_CTX *,
210
        BN_CTX_new,
211
        (void),
212
        NULL,
213
        (),
214
        1
215
)
216
217
WRAP(BIGNUM *,
218
        BN_new,
219
        (void),
220
        NULL,
221
        (),
222
        1
223
)
224
225
WRAP(RSA *,
226
        RSA_new,
227
        (void),
228
        NULL,
229
        (),
230
        1
231
)
232
233
WRAP(int,
234
        RSA_set0_key,
235
        (RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d),
236
        0,
237
        (r, n, e, d),
238
        1
239
)
240
241
WRAP(int,
242
        RSA_pkey_ctx_ctrl,
243
        (EVP_PKEY_CTX *ctx, int optype, int cmd, int p1, void *p2),
244
        -1,
245
        (ctx, optype, cmd, p1, p2),
246
        1
247
)
248
249
WRAP(EC_KEY *,
250
        EC_KEY_new_by_curve_name,
251
        (int nid),
252
        NULL,
253
        (nid),
254
        1
255
)
256
257
WRAP(const EC_GROUP *,
258
        EC_KEY_get0_group,
259
        (const EC_KEY *key),
260
        NULL,
261
        (key),
262
        1
263
)
264
265
WRAP(const BIGNUM *,
266
        EC_KEY_get0_private_key,
267
        (const EC_KEY *key),
268
        NULL,
269
        (key),
270
        1
271
)
272
273
WRAP(EC_POINT *,
274
        EC_POINT_new,
275
        (const EC_GROUP *group),
276
        NULL,
277
        (group),
278
        1
279
)
280
281
WRAP(int,
282
        EC_POINT_get_affine_coordinates_GFp,
283
        (const EC_GROUP *group, const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx),
284
        0,
285
        (group, p, x, y, ctx),
286
        1
287
)
288
289
WRAP(EVP_PKEY *,
290
        EVP_PKEY_new,
291
        (void),
292
        NULL,
293
        (),
294
        1
295
)
296
297
WRAP(int,
298
        EVP_PKEY_assign,
299
        (EVP_PKEY *pkey, int type, void *key),
300
        0,
301
        (pkey, type, key),
302
        1
303
)
304
305
WRAP(int,
306
        EVP_PKEY_keygen_init,
307
        (EVP_PKEY_CTX *ctx),
308
        0,
309
        (ctx),
310
        1
311
)
312
313
WRAP(int,
314
        EVP_PKEY_keygen,
315
        (EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey),
316
        0,
317
        (ctx, ppkey),
318
        1
319
)
320
321
WRAP(int,
322
        EVP_PKEY_paramgen_init,
323
        (EVP_PKEY_CTX *ctx),
324
        0,
325
        (ctx),
326
        1
327
)
328
329
WRAP(int,
330
        EVP_PKEY_paramgen,
331
        (EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey),
332
        0,
333
        (ctx, ppkey),
334
        1
335
)
336
337
WRAP(EVP_PKEY *,
338
        EVP_PKEY_new_raw_public_key,
339
        (int type, ENGINE *e, const unsigned char *key, size_t keylen),
340
        NULL,
341
        (type, e, key, keylen),
342
        1
343
)
344
345
WRAP(EVP_PKEY_CTX *,
346
        EVP_PKEY_CTX_new,
347
        (EVP_PKEY *pkey, ENGINE *e),
348
        NULL,
349
        (pkey, e),
350
        1
351
)
352
353
WRAP(EVP_PKEY_CTX *,
354
        EVP_PKEY_CTX_new_id,
355
        (int id, ENGINE *e),
356
        NULL,
357
        (id, e),
358
        1
359
)
360
361
WRAP(int,
362
        EVP_PKEY_derive,
363
        (EVP_PKEY_CTX *ctx, unsigned char *key, size_t *pkeylen),
364
        0,
365
        (ctx, key, pkeylen),
366
        1
367
)
368
369
WRAP(int,
370
        EVP_PKEY_derive_init,
371
        (EVP_PKEY_CTX *ctx),
372
        0,
373
        (ctx),
374
        1
375
)
376
377
WRAP(int,
378
        EVP_PKEY_derive_set_peer,
379
        (EVP_PKEY_CTX *ctx, EVP_PKEY *peer),
380
        0,
381
        (ctx, peer),
382
        1
383
)
384
385
WRAP(int,
386
        EVP_PKEY_verify_init,
387
        (EVP_PKEY_CTX *ctx),
388
        0,
389
        (ctx),
390
        1
391
)
392
393
WRAP(int,
394
        EVP_PKEY_CTX_ctrl,
395
        (EVP_PKEY_CTX *ctx, int keytype, int optype, int cmd, int p1, void *p2),
396
        -1,
397
        (ctx, keytype, optype, cmd, p1, p2),
398
        1
399
)
400
401
WRAP(const EVP_MD *,
402
        EVP_sha1,
403
        (void),
404
        NULL,
405
        (),
406
        1
407
)
408
409
WRAP(const EVP_MD *,
410
        EVP_sha256,
411
        (void),
412
        NULL,
413
        (),
414
        1
415
)
416
417
WRAP(const EVP_CIPHER *,
418
        EVP_aes_256_cbc,
419
        (void),
420
        NULL,
421
        (),
422
        1
423
)
424
425
WRAP(const EVP_CIPHER *,
426
        EVP_aes_256_gcm,
427
        (void),
428
        NULL,
429
        (),
430
        1
431
)
432
433
WRAP(unsigned char *,
434
        HMAC,
435
        (const EVP_MD *evp_md, const void *key, int key_len,
436
            const unsigned char *d, int n, unsigned char *md,
437
            unsigned int *md_len),
438
        NULL,
439
        (evp_md, key, key_len, d, n, md, md_len),
440
        1
441
)
442
443
WRAP(HMAC_CTX *,
444
        HMAC_CTX_new,
445
        (void),
446
        NULL,
447
        (),
448
        1
449
)
450
451
WRAP(int,
452
        HMAC_Init_ex,
453
        (HMAC_CTX *ctx, const void *key, int key_len, const EVP_MD *md,
454
            ENGINE *impl),
455
        0,
456
        (ctx, key, key_len, md, impl),
457
        1
458
)
459
460
WRAP(int,
461
        HMAC_Update,
462
        (HMAC_CTX *ctx, const unsigned char *data, int len),
463
        0,
464
        (ctx, data, len),
465
        1
466
)
467
468
WRAP(int,
469
        HMAC_Final,
470
        (HMAC_CTX *ctx, unsigned char *md, unsigned int *len),
471
        0,
472
        (ctx, md, len),
473
        1
474
)
475
476
WRAP(unsigned char *,
477
        SHA1,
478
        (const unsigned char *d, size_t n, unsigned char *md),
479
        NULL,
480
        (d, n, md),
481
        1
482
)
483
484
WRAP(unsigned char *,
485
        SHA256,
486
        (const unsigned char *d, size_t n, unsigned char *md),
487
        NULL,
488
        (d, n, md),
489
        1
490
)
491
492
WRAP(cbor_item_t *,
493
        cbor_build_string,
494
        (const char *val),
495
        NULL,
496
        (val),
497
        1
498
)
499
500
WRAP(cbor_item_t *,
501
        cbor_build_bytestring,
502
        (cbor_data handle, size_t length),
503
        NULL,
504
        (handle, length),
505
        1
506
)
507
508
WRAP(cbor_item_t *,
509
        cbor_build_bool,
510
        (bool value),
511
        NULL,
512
        (value),
513
        1
514
)
515
516
WRAP(cbor_item_t *,
517
        cbor_build_negint8,
518
        (uint8_t value),
519
        NULL,
520
        (value),
521
        1
522
)
523
524
WRAP(cbor_item_t *,
525
        cbor_build_negint16,
526
        (uint16_t value),
527
        NULL,
528
        (value),
529
        1
530
)
531
532
WRAP(cbor_item_t *,
533
        cbor_load,
534
        (cbor_data source, size_t source_size, struct cbor_load_result *result),
535
        NULL,
536
        (source, source_size, result),
537
        1
538
)
539
540
WRAP(cbor_item_t *,
541
        cbor_build_uint8,
542
        (uint8_t value),
543
        NULL,
544
        (value),
545
        1
546
)
547
548
WRAP(cbor_item_t *,
549
        cbor_build_uint16,
550
        (uint16_t value),
551
        NULL,
552
        (value),
553
        1
554
)
555
556
WRAP(cbor_item_t *,
557
        cbor_build_uint32,
558
        (uint32_t value),
559
        NULL,
560
        (value),
561
        1
562
)
563
564
WRAP(cbor_item_t *,
565
        cbor_build_uint64,
566
        (uint64_t value),
567
        NULL,
568
        (value),
569
        1
570
)
571
572
WRAP(struct cbor_pair *,
573
        cbor_map_handle,
574
        (const cbor_item_t *item),
575
        NULL,
576
        (item),
577
        1
578
)
579
580
WRAP(cbor_item_t **,
581
        cbor_array_handle,
582
        (const cbor_item_t *item),
583
        NULL,
584
        (item),
585
        1
586
)
587
588
WRAP(bool,
589
        cbor_array_push,
590
        (cbor_item_t *array, cbor_item_t *pushee),
591
        false,
592
        (array, pushee),
593
        1
594
)
595
596
WRAP(bool,
597
        cbor_map_add,
598
        (cbor_item_t *item, struct cbor_pair pair),
599
        false,
600
        (item, pair),
601
        1
602
)
603
604
WRAP(cbor_item_t *,
605
        cbor_new_definite_map,
606
        (size_t size),
607
        NULL,
608
        (size),
609
        1
610
)
611
612
WRAP(cbor_item_t *,
613
        cbor_new_definite_array,
614
        (size_t size),
615
        NULL,
616
        (size),
617
        1
618
)
619
620
WRAP(cbor_item_t *,
621
        cbor_new_definite_bytestring,
622
        (void),
623
        NULL,
624
        (),
625
        1
626
)
627
628
WRAP(size_t,
629
        cbor_serialize_alloc,
630
        (const cbor_item_t *item, cbor_mutable_data *buffer,
631
            size_t *buffer_size),
632
        0,
633
        (item, buffer, buffer_size),
634
        1
635
)
636
637
WRAP(int,
638
        fido_tx,
639
        (fido_dev_t *d, uint8_t cmd, const void *buf, size_t count, int *ms),
640
        -1,
641
        (d, cmd, buf, count, ms),
642
        1
643
)
644
645
WRAP(int,
646
        bind,
647
        (int sockfd, const struct sockaddr *addr, socklen_t addrlen),
648
        -1,
649
        (sockfd, addr, addrlen),
650
        1
651
)
652
653
WRAP(int,
654
        deflateInit2_,
655
        (z_streamp strm, int level, int method, int windowBits, int memLevel,
656
            int strategy, const char *version, int stream_size),
657
        Z_STREAM_ERROR,
658
        (strm, level, method, windowBits, memLevel, strategy, version,
659
            stream_size),
660
        1
661
)
662
663
int __wrap_deflate(z_streamp, int);
664
int __real_deflate(z_streamp, int);
665
666
int
667
__wrap_deflate(z_streamp strm, int flush)
668
479
{
669
479
        if (prng_up && uniform_random(400) < 1) {
670
1
                return Z_BUF_ERROR;
671
1
        }
672
        /* should never happen, but we check for it */
673
478
        if (prng_up && uniform_random(400) < 1) {
674
1
                strm->avail_out = UINT_MAX;
675
1
                return Z_STREAM_END;
676
1
        }
677
678
477
        return __real_deflate(strm, flush);
679
478
}
680
681
int __wrap_asprintf(char **, const char *, ...);
682
683
int
684
__wrap_asprintf(char **strp, const char *fmt, ...)
685
457k
{
686
457k
        va_list ap;
687
457k
        int r;
688
689
457k
        if (prng_up && uniform_random(400) < 1) {
690
1.23k
                *strp = (void *)0xdeadbeef;
691
1.23k
                return -1;
692
1.23k
        }
693
694
456k
        va_start(ap, fmt);
695
456k
        r = vasprintf(strp, fmt, ap);
696
456k
        va_end(ap);
697
698
456k
        return r;
699
457k
}