Skip to content

Commit ce3dfd0

Browse files
committed
fuzz: introduce fuzz/fido_fuzz.h
A header including the prototypes of the functions we borrow from libfido2 fuzzing instrumentation. By having them into a separate header we make it simpler the addition of configure-time checks on the availability of these functions.
1 parent 2be940f commit ce3dfd0

File tree

6 files changed

+18
-7
lines changed

6 files changed

+18
-7
lines changed

fuzz/fido_fuzz.h

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* Copyright (C) 2025 Yubico AB - See COPYING */
2+
#ifndef FIDO_FUZZ_H
3+
#define FIDO_FUZZ_H
4+
5+
#include <stdint.h>
6+
7+
/* part of libfido2's fuzzing instrumentation, requires build with -DFUZZ=1 */
8+
extern int prng_up;
9+
void prng_init(unsigned long);
10+
uint32_t uniform_random(uint32_t);
11+
12+
#endif /* FIDO_FUZZ_H */

fuzz/fuzz.h

-4
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,4 @@ int unpack_blob(const uint8_t **, size_t *, struct blob *);
3131
int pack_string(uint8_t **, size_t *, const char *);
3232
int unpack_string(const uint8_t **, size_t *, char *);
3333

34-
/* part of libfido2's fuzzing instrumentation, requires build with -DFUZZ=1 */
35-
void prng_init(unsigned long);
36-
uint32_t uniform_random(uint32_t);
37-
3834
#endif

fuzz/fuzz_auth.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
#include <unistd.h>
1313

1414
#include "cfg.h"
15+
16+
#include "fuzz/authfile.h"
17+
#include "fuzz/fido_fuzz.h"
1518
#include "fuzz/fuzz.h"
1619
#include "fuzz/wiredata.h"
17-
#include "fuzz/authfile.h"
1820

1921
#define MUTATE_SEED 0x01
2022
#define MUTATE_PARAM 0x02

fuzz/fuzz_format_parsers.c

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <string.h>
1111
#include <unistd.h>
1212

13+
#include "fuzz/fido_fuzz.h"
1314
#include "fuzz/fuzz.h"
1415
#include "util.h"
1516

fuzz/pack.c

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <string.h>
55
#include <arpa/inet.h>
66

7+
#include "fuzz/fido_fuzz.h"
78
#include "fuzz/fuzz.h"
89

910
static int do_unpack(const uint8_t **buf, size_t *rem, uint8_t *dst,

fuzz/wrap.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@
1717

1818
#include "debug.h"
1919
#include "drop_privs.h"
20+
#include "fuzz/fido_fuzz.h"
2021
#include "fuzz/fuzz.h"
2122

22-
extern int prng_up;
23-
2423
#ifdef HAVE_PAM_MODUTIL_DROP_PRIV
2524
typedef struct pam_modutil_privs fuzz_privs_t;
2625
#else

0 commit comments

Comments
 (0)