Skip to content

Commit

Permalink
Emit pre/post callbacks while fuzzing
Browse files Browse the repository at this point in the history
  • Loading branch information
uNetworkingAB committed Jan 11, 2020
1 parent d6954ba commit 5d0d821
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions fuzzing/uSocketsMock.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ struct us_loop_t {

/* The list of closed sockets */
struct us_socket_t *close_list;

/* Post and pre callbacks */
void (*pre_cb)(struct us_loop_t *loop);
void (*post_cb)(struct us_loop_t *loop);
};

struct us_loop_t *us_create_loop(void *hint, void (*wakeup_cb)(struct us_loop_t *loop), void (*pre_cb)(struct us_loop_t *loop), void (*post_cb)(struct us_loop_t *loop), unsigned int ext_size) {
Expand All @@ -21,6 +25,9 @@ struct us_loop_t *us_create_loop(void *hint, void (*wakeup_cb)(struct us_loop_t
loop->listen_socket = 0;
loop->close_list = 0;

loop->pre_cb = pre_cb;
loop->post_cb = post_cb;

return loop;
}

Expand Down Expand Up @@ -215,6 +222,9 @@ void us_loop_read_mocked_data(struct us_loop_t *loop, char *data, unsigned int s
/* We are unwound so let's free all closed polls here */


/* Call pre_cb */
loop->pre_cb(loop);

/* We have one listen socket */
int socket_ext_size = loop->listen_socket->socket_ext_size;

Expand Down Expand Up @@ -282,4 +292,7 @@ void us_loop_read_mocked_data(struct us_loop_t *loop, char *data, unsigned int s

/* Free the socket */
free(s);

/* Call post_cb */
loop->post_cb(loop);
}

0 comments on commit 5d0d821

Please sign in to comment.