dfuzzer
Macros | Functions
rand.h File Reference

Go to the source code of this file.

Macros

#define MINLEN   512
 
#define MAX_BUF_LEN   50000
 
#define MAXLEN   256
 
#define MAXSIG   255
 
#define MAX_FUZZ_COUNTER   1000
 

Functions

void df_rand_init (const long buf_size)
 
guint8 df_rand_guint8 (void)
 
gboolean df_rand_gboolean (void)
 
gint16 df_rand_gint16 (void)
 
guint16 df_rand_guint16 (void)
 
gint32 df_rand_gint32 (void)
 
guint32 df_rand_guint32 (void)
 
gint64 df_rand_gint64 (void)
 
guint64 df_rand_guint64 (void)
 
double drand (void)
 
gdouble df_rand_gdouble (void)
 
int df_rand_continue (const int fuzz_on_str_len)
 
int df_rand_string (gchar **buf)
 
int df_rand_dbus_objpath_string (gchar **buf)
 
int df_rand_dbus_signature_string (gchar **buf)
 
int df_rand_GVariant (GVariant **var)
 
int df_rand_unixFD (void)
 

Macro Definition Documentation

§ MAX_BUF_LEN

#define MAX_BUF_LEN   50000

Maximum buffer size for generated strings, default is cca 50 kB

§ MAX_FUZZ_COUNTER

#define MAX_FUZZ_COUNTER   1000

Maximum number of generations of non-string values (for functions without string arguments)

§ MAXLEN

#define MAXLEN   256

Maximum length of strings containing D-Bus object path

§ MAXSIG

#define MAXSIG   255

Maximum length of D-Bus signature string

§ MINLEN

#define MINLEN   512

Minimal buffer size for generated strings

Function Documentation

§ df_rand_continue()

int df_rand_continue ( const int  fuzz_on_str_len)

Tells callee whether to continue testing according to current size of generated strings not to exceed df_buf_size length.

Parameters
fuzz_on_str_lenIf 1, fuzzing will be controlled by generated random strings lengths
Returns
1 when callee should continue, 0 otherwise

§ df_rand_dbus_objpath_string()

int df_rand_dbus_objpath_string ( gchar **  buf)

Allocates memory for pseudo-random object path string of size counted by adding 1 to size variable on every call of function to maximum size of MAXLEN. On every call pseudo-random object path string is generated into buf buffer. Warning: buf should be freed outside this module by callee of this function.

Parameters
bufAddress of pointer on buffer where generated object path string will be stored
Returns
0 on success, -1 on error

§ df_rand_dbus_signature_string()

int df_rand_dbus_signature_string ( gchar **  buf)

Allocates memory for pseudo-random signature string of size counted by adding 1 to size variable on every call of function to maximum size of MAXSIG. On every call pseudo-random signature string is generated by random access into global variable df_sig_def which contains all D-Bus signatures and copying signature into buf buffer. Warning: buf should be freed outside this module by callee of this function.

Parameters
bufAddress of pointer on buffer where generated signature string will be stored
Returns
0 on success, -1 on error

§ df_rand_gboolean()

gboolean df_rand_gboolean ( void  )
Returns
Generated pseudo-random boolean value

§ df_rand_gdouble()

gdouble df_rand_gdouble ( void  )
Returns
Generated pseudo-random double precision floating point number

§ df_rand_gint16()

gint16 df_rand_gint16 ( void  )
Returns
Generated pseudo-random 16-bit integer value

§ df_rand_gint32()

gint32 df_rand_gint32 ( void  )
Returns
Generated pseudo-random 32-bit integer value

§ df_rand_gint64()

gint64 df_rand_gint64 ( void  )
Returns
Generated pseudo-random 64-bit (long) integer value

§ df_rand_guint16()

guint16 df_rand_guint16 ( void  )
Returns
Generated pseudo-random 16-bit unsigned integer value

§ df_rand_guint32()

guint32 df_rand_guint32 ( void  )
Returns
Generated pseudo-random 32-bit unsigned integer value

§ df_rand_guint64()

guint64 df_rand_guint64 ( void  )
Returns
Generated pseudo-random 64-bit (long) unsigned integer value

§ df_rand_guint8()

guint8 df_rand_guint8 ( void  )
Returns
Generated pseudo-random 8-bit unsigned integer value

§ df_rand_GVariant()

int df_rand_GVariant ( GVariant **  var)

Creates Gvariant containing pseudo-random string. At the beginning strings from global array df_str_def are used.

Parameters
varAddress of pointer on GVariant where new Gvariant value will be stored
Returns
0 on success, -1 on error

§ df_rand_init()

void df_rand_init ( const long  buf_size)

Initializes global flag variables and seeds pseudo-random numbers generators.

Parameters
buf_sizeMaximum buffer size for generated strings (in Bytes)

§ df_rand_string()

int df_rand_string ( gchar **  buf)

Allocates memory for pseudo-random string of size counted by adding generated pseudo-random number from interval <0, CHAR_MAX> to df_str_len (this mechanism is responsible for generating bigger strings by every call of df_rand_string()). Then pseudo-random string is generated and stored in buf. At the beginning strings from global array df_str_def are used. Warning: buf should be freed outside this module by callee of this function.

Parameters
bufAddress of pointer on buffer where generated string will be stored
Returns
0 on success, -1 on error

§ df_rand_unixFD()

int df_rand_unixFD ( void  )
Returns
Generated pseudo-random FD number from interval <-1, INT_MAX)

§ drand()

double drand ( void  )
inline
Returns
Generated pseudo-random double precision floating point number from interval <0, 1>