dfuzzer
 All Data Structures Files Functions Variables Macros
Data Structures | Macros | Functions
fuzz.h File Reference

Go to the source code of this file.

Data Structures

struct  df_signature
 
struct  df_sig_list
 

Macros

#define MAXSIG   255
 
#define MAXFMT   MAXSIG * 2
 
#define MAXLINE   1024
 
#define MAX_EXCEPTIONS   10
 

Functions

int df_ewrite (int fd, const void *buf, size_t count)
 
int df_fuzz_init (GDBusProxy *dproxy, const int statfd, const int pid, const long mem_limit)
 
int df_fuzz_add_method (const char *name)
 
int df_fuzz_add_method_arg (const char *signature)
 
int df_list_args_count (void)
 
int df_fuzz_test_method (const int statfd, long buf_size, const char *name, const char *obj, const char *intf, const int pid, const int void_method, const char *execute_cmd)
 
void df_fuzz_clean_method (void)
 

Macro Definition Documentation

#define MAX_EXCEPTIONS   10

Maximum amount of unimportant exceptions for one method; if reached testing continues with a next method

#define MAXFMT   MAXSIG * 2

MAXSIG * 2 because of '@' character for every signature

#define MAXLINE   1024

Maximum length read from file

#define MAXSIG   255

Maximum length of D-Bus signature string

Function Documentation

int df_ewrite ( int  fd,
const void *  buf,
size_t  count 
)
inline

Error checked write function with short write correction (when write is interrupted by a signal).

Parameters
fdFile descriptor where to write
bufBuffer from which to write to file descriptor fd
countNumber of bytes to be written
Returns
0 on success, -1 on error
int df_fuzz_add_method ( const char *  name)

Initializes the global variable df_list (struct df_sig_list) including allocationg memory for method name inside df_list.

Parameters
nameName of method which will be tested
Returns
0 on success, -1 on error
int df_fuzz_add_method_arg ( const char *  signature)

Adds item (struct df_signature) at the end of the linked list in the global variable df_list (struct df_sig_list). This includes allocating memory for item and for signature string.

Parameters
signatureD-Bus signature of the argument
Returns
0 on success, -1 on error
void df_fuzz_clean_method ( void  )

Releases memory used by this module. This function must be called after df_fuzz_add_method() and df_fuzz_add_method_arg() functions calls after the end of fuzz testing of each method.

int df_fuzz_init ( GDBusProxy *  dproxy,
const int  statfd,
const int  pid,
const long  mem_limit 
)

Saves pointer on D-Bus interface proxy for this module to be able to call methods through this proxy during fuzz testing. Also saves process initial memory size to global var. df_initial_mem from file described by statfd.

Parameters
dproxyPointer on D-Bus interface proxy
statfdFD of process status file
pidPID of tested process
mem_limitMemory limit in kB - if tested process exceeds this limit it will be noted into log file
Returns
0 on success, -1 on error
int df_fuzz_test_method ( const int  statfd,
long  buf_size,
const char *  name,
const char *  obj,
const char *  intf,
const int  pid,
const int  void_method,
const char *  execute_cmd 
)

Function is testing a method in a cycle, each cycle generates data for function arguments, calls method and waits for result.

Parameters
statfdFD of process status file
buf_sizeMaximum buffer size for generated strings by rand module (in Bytes)
nameD-Bus name
objD-Bus object path
intfD-Bus interface
pidPID of tested process
void_methodIf method has out args 1, 0 otherwise
execute_cmdCommand/Script to execute after each method call.
Returns
0 on success, -1 on error, 1 on tested process crash, 2 on void function returning non-void value, 3 on warnings and 4 when executed command finished unsuccessfuly
int df_list_args_count ( void  )
Returns
Number of arguments of tested method