Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cmp_tool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dominik Loidolt
cmp_tool
Commits
78e6bbff
Commit
78e6bbff
authored
3 months ago
by
Dominik Loidolt
Browse files
Options
Downloads
Patches
Plain Diff
Refactor cmp_tool fuzzing
parent
bd0a4667
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
test/fuzz/fuzz_cmp_tool.c
+2
-1
2 additions, 1 deletion
test/fuzz/fuzz_cmp_tool.c
test/fuzz/fuzz_data_producer.h
+20
-8
20 additions, 8 deletions
test/fuzz/fuzz_data_producer.h
test/fuzz/fuzz_helpers.c
+2
-5
2 additions, 5 deletions
test/fuzz/fuzz_helpers.c
with
24 additions
and
14 deletions
test/fuzz/fuzz_cmp_tool.c
+
2
−
1
View file @
78e6bbff
...
@@ -59,7 +59,8 @@ static int gen_argv(FUZZ_dataProducer_t *producer, char **argv, const char *data
...
@@ -59,7 +59,8 @@ static int gen_argv(FUZZ_dataProducer_t *producer, char **argv, const char *data
/* Add optional arguments no the end so they have higher priority */
/* Add optional arguments no the end so they have higher priority */
end
=
argc
-
1
;
end
=
argc
-
1
;
add_argument_with_file
(
argv
,
end
--
,
"-o"
,
"/tmp/fuzz-output-cmp_tool"
);
/* TODO: How to clean up written stuff by the cmp_tool? */
add_argument_with_file
(
argv
,
end
--
,
"-o"
,
FUZZ_TMP_DIR
"/fuzz-output-cmp_tool"
);
if
(
FUZZ_dataProducer_uint32Range
(
producer
,
0
,
1
))
if
(
FUZZ_dataProducer_uint32Range
(
producer
,
0
,
1
))
add_argument_with_file
(
argv
,
end
--
,
"-d"
,
data_file
);
add_argument_with_file
(
argv
,
end
--
,
"-d"
,
data_file
);
if
(
FUZZ_dataProducer_uint32Range
(
producer
,
0
,
1
))
if
(
FUZZ_dataProducer_uint32Range
(
producer
,
0
,
1
))
...
...
This diff is collapsed.
Click to expand it.
test/fuzz/fuzz_data_producer.h
+
20
−
8
View file @
78e6bbff
...
@@ -29,13 +29,21 @@
...
@@ -29,13 +29,21 @@
#ifndef FUZZ_DATA_PRODUCER_H
#ifndef FUZZ_DATA_PRODUCER_H
#define FUZZ_DATA_PRODUCER_H
#define FUZZ_DATA_PRODUCER_H
#include
<stddef.h>
#include
<stddef.h>
#include
<stdint.h>
#include
<stdint.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<stdlib.h>
#include
<cmp_chunk.h>
#include
<cmp_chunk.h>
#ifdef __APPLE__
# define FUZZ_TMP_DIR "/tmp"
#else
# define FUZZ_TMP_DIR "/dev/shm"
#endif
/* Struct used for maintaining the state of the data */
/* Struct used for maintaining the state of the data */
typedef
struct
FUZZ_dataProducer_s
FUZZ_dataProducer_t
;
typedef
struct
FUZZ_dataProducer_s
FUZZ_dataProducer_t
;
...
@@ -47,14 +55,14 @@ void FUZZ_dataProducer_free(FUZZ_dataProducer_t *producer);
...
@@ -47,14 +55,14 @@ void FUZZ_dataProducer_free(FUZZ_dataProducer_t *producer);
/* Returns value between [min, max] */
/* Returns value between [min, max] */
uint32_t
FUZZ_dataProducer_uint32Range
(
FUZZ_dataProducer_t
*
producer
,
uint32_t
min
,
uint32_t
FUZZ_dataProducer_uint32Range
(
FUZZ_dataProducer_t
*
producer
,
uint32_t
min
,
uint32_t
max
);
uint32_t
max
);
/* Returns a uint32 value */
/* Returns a uint32 value */
uint32_t
FUZZ_dataProducer_uint32
(
FUZZ_dataProducer_t
*
producer
);
uint32_t
FUZZ_dataProducer_uint32
(
FUZZ_dataProducer_t
*
producer
);
/* Returns a signed value between [min, max] */
/* Returns a signed value between [min, max] */
int32_t
FUZZ_dataProducer_int32Range
(
FUZZ_dataProducer_t
*
producer
,
int32_t
FUZZ_dataProducer_int32Range
(
FUZZ_dataProducer_t
*
producer
,
int32_t
min
,
int32_t
max
);
int32_t
min
,
int32_t
max
);
/* Provides compression parameters */
/* Provides compression parameters */
void
FUZZ_dataProducer_cmp_par
(
FUZZ_dataProducer_t
*
producer
,
struct
cmp_par
*
cmp_par
);
void
FUZZ_dataProducer_cmp_par
(
FUZZ_dataProducer_t
*
producer
,
struct
cmp_par
*
cmp_par
);
...
@@ -69,12 +77,16 @@ void FUZZ_dataProducer_rollBack(FUZZ_dataProducer_t *producer, size_t remainingB
...
@@ -69,12 +77,16 @@ void FUZZ_dataProducer_rollBack(FUZZ_dataProducer_t *producer, size_t remainingB
int
FUZZ_dataProducer_empty
(
FUZZ_dataProducer_t
*
producer
);
int
FUZZ_dataProducer_empty
(
FUZZ_dataProducer_t
*
producer
);
/* Restricts the producer to only the last newSize bytes of data.
/* Restricts the producer to only the last newSize bytes of data.
If newSize > current data size, nothing happens. Returns the number of bytes
* If newSize > current data size, nothing happens. Returns the number of bytes
the producer won't use anymore, after contracting. */
* the producer won't use anymore, after contracting.
*/
size_t
FUZZ_dataProducer_contract
(
FUZZ_dataProducer_t
*
producer
,
size_t
newSize
);
size_t
FUZZ_dataProducer_contract
(
FUZZ_dataProducer_t
*
producer
,
size_t
newSize
);
/* Restricts the producer to use only the last X bytes of data, where X is
/* Restricts the producer to use only the last X bytes of data, where X is a
a random number in the interval [0, data_size]. Returns the size of the
* random number in the interval [0, data_size]. Returns the size of the
remaining data the producer won't use anymore (the prefix). */
* remaining data the producer won't use anymore (the prefix).
*/
size_t
FUZZ_dataProducer_reserveDataPrefix
(
FUZZ_dataProducer_t
*
producer
);
size_t
FUZZ_dataProducer_reserveDataPrefix
(
FUZZ_dataProducer_t
*
producer
);
#endif // FUZZ_DATA_PRODUCER_H
#endif // FUZZ_DATA_PRODUCER_H
This diff is collapsed.
Click to expand it.
test/fuzz/fuzz_helpers.c
+
2
−
5
View file @
78e6bbff
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
#include
<errno.h>
#include
<errno.h>
#include
"fuzz_helpers.h"
#include
"fuzz_helpers.h"
#include
"fuzz_data_producer.h"
void
*
FUZZ_malloc
(
size_t
size
)
void
*
FUZZ_malloc
(
size_t
size
)
...
@@ -61,11 +62,7 @@ char *FUZZ_buf_to_file(const uint8_t *buf, size_t size)
...
@@ -61,11 +62,7 @@ char *FUZZ_buf_to_file(const uint8_t *buf, size_t size)
int
fd
,
ret_close
;
int
fd
,
ret_close
;
size_t
pos
=
0
;
size_t
pos
=
0
;
#ifdef __APPLE__
char
*
path_name
=
strdup
(
FUZZ_TMP_DIR
"/fuzz-XXXXXX"
);
char
*
path_name
=
strdup
(
"/tmp/fuzz-XXXXXX"
);
#else
char
*
path_name
=
strdup
(
"/dev/shm/fuzz-XXXXXX"
);
#endif
FUZZ_ASSERT
(
path_name
!=
NULL
);
FUZZ_ASSERT
(
path_name
!=
NULL
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment