Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Knot DNS
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
22
Issues
22
List
Boards
Labels
Service Desk
Milestones
Merge Requests
16
Merge Requests
16
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Knot projects
Knot DNS
Commits
e436100d
Commit
e436100d
authored
Aug 10, 2015
by
Vitezslav Kriz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
afl-persistent: wrap udp with stdio.
#349
parent
322f3986
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
110 additions
and
3 deletions
+110
-3
tests-fuzz/Makefile.am
tests-fuzz/Makefile.am
+14
-3
tests-fuzz/wrap/server.c
tests-fuzz/wrap/server.c
+18
-0
tests-fuzz/wrap/udp-handler.c
tests-fuzz/wrap/udp-handler.c
+78
-0
No files found.
tests-fuzz/Makefile.am
View file @
e436100d
AM_CPPFLAGS
=
\
-include
$(top_builddir)
/src/config.h
\
-I
$(top_srcdir)
/src
# -I$(top_srcdir)/src/dnssec/lib
-I
$(top_srcdir)
/src
\
-I
$(top_srcdir)
/src/dnssec/lib
LDADD
=
\
$(top_builddir)
/src/libknot.la
noinst_PROGRAMS
=
\
packet
packet
\
knotd_stdio
knotd_stdio_SOURCES
=
wrap/udp-handler.c wrap/server.c
knotd_stdio_CPPFLAGS
=
$(AM_CPPFLAGS)
$(liburcu_CFLAGS)
knotd_stdio_LDADD
=
\
$(top_builddir)
/src/knot/knotd-main.o
\
$(top_builddir)
/src/libknotd.la
$(liburcu_LIBS)
tests-fuzz/wrap/server.c
0 → 100644
View file @
e436100d
/*
* Wrap function server_reconfigure to initialize udp_master to stdin
*/
#define server_reconfigure _orig_server_reconfigure
#include "knot/server/server.c"
#undef server_reconfigure
extern
void
udp_master_init_stdio
(
server_t
*
server
);
int
server_reconfigure
(
conf_t
*
conf
,
void
*
data
)
{
log_info
(
"AFL, Wrap server_reconfigure()"
);
int
ret
=
_orig_server_reconfigure
(
conf
,
data
);
udp_master_init_stdio
(
data
);
return
ret
;
}
tests-fuzz/wrap/udp-handler.c
0 → 100644
View file @
e436100d
#include "knot/server/udp-handler.c"
#include "knot/common/debug.h"
/*
* Udp handler listen on stdin and send to stdout.
* To use this handler initialize it with udp_master_init_stdin.
*/
struct
udp_stdin
{
struct
iovec
iov
[
NBUFS
];
uint8_t
buf
[
NBUFS
][
KNOT_WIRE_MAX_PKTSIZE
];
struct
sockaddr_storage
addr
;
};
static
void
*
udp_stdin_init
(
void
)
{
struct
udp_stdin
*
rq
=
malloc
(
sizeof
(
struct
udp_stdin
));
memset
(
rq
,
0
,
sizeof
(
struct
udp_stdin
));
for
(
unsigned
i
=
0
;
i
<
NBUFS
;
++
i
)
{
rq
->
iov
[
i
].
iov_base
=
rq
->
buf
[
i
];
rq
->
iov
[
i
].
iov_len
=
KNOT_WIRE_MAX_PKTSIZE
;
}
return
rq
;
}
static
int
udp_stdin_deinit
(
void
*
d
)
{
free
(
d
);
return
0
;
}
static
int
udp_stdin_recv
(
int
fd
,
void
*
d
)
{
struct
udp_stdin
*
rq
=
(
struct
udp_stdin
*
)
d
;
rq
->
iov
[
RX
].
iov_len
=
fread
(
rq
->
iov
[
RX
].
iov_base
,
1
,
rq
->
iov
[
RX
].
iov_len
,
stdin
);
return
rq
->
iov
[
RX
].
iov_len
;
}
static
int
udp_stdin_handle
(
udp_context_t
*
ctx
,
void
*
d
)
{
struct
udp_stdin
*
rq
=
(
struct
udp_stdin
*
)
d
;
udp_handle
(
ctx
,
STDIN_FILENO
,
&
rq
->
addr
,
&
rq
->
iov
[
RX
],
&
rq
->
iov
[
TX
]);
return
0
;
}
static
int
udp_stdin_send
(
void
*
d
)
{
struct
udp_stdin
*
rq
=
(
struct
udp_stdin
*
)
d
;
fwrite
(
rq
->
iov
[
TX
].
iov_base
,
1
,
rq
->
iov
[
TX
].
iov_len
,
stdout
);
if
(
getenv
(
"AFL_PERSISTENT"
))
{
raise
(
SIGSTOP
);
}
else
{
exit
(
0
);
}
return
0
;
}
/*!
* \brief Initialize udp_handler with stdio
*/
void
udp_master_init_stdio
(
server_t
*
server
)
{
log_info
(
"AFL, UDP handler listen on stdin"
);
// register our dummy interface to server
iface_t
*
ifc
=
malloc
(
sizeof
(
iface_t
));
ifc
->
fd
[
RX
]
=
STDIN_FILENO
;
ifc
->
fd
[
TX
]
=
STDOUT_FILENO
;
add_tail
(
&
server
->
ifaces
->
l
,
(
node_t
*
)
ifc
);
_udp_init
=
udp_stdin_init
;
_udp_recv
=
udp_stdin_recv
;
_udp_handle
=
udp_stdin_handle
;
_udp_send
=
udp_stdin_send
;
_udp_deinit
=
udp_stdin_deinit
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment