Overanalyzing
This commit is contained in:
parent
da9daa39cc
commit
7f2b6c9a36
1 changed files with 6 additions and 4 deletions
10
src/pcapng.c
10
src/pcapng.c
|
@ -11,7 +11,8 @@
|
||||||
ssize_t hexagram_pcapng_read_options(hexagram_pcapng_stream *stream,
|
ssize_t hexagram_pcapng_read_options(hexagram_pcapng_stream *stream,
|
||||||
hexagram_pcapng_option_handler *handler,
|
hexagram_pcapng_option_handler *handler,
|
||||||
uint32_t type,
|
uint32_t type,
|
||||||
size_t len) {
|
size_t len,
|
||||||
|
void *data) {
|
||||||
hexagram_pcapng_option option;
|
hexagram_pcapng_option option;
|
||||||
ssize_t total = 0;
|
ssize_t total = 0;
|
||||||
|
|
||||||
|
@ -26,7 +27,7 @@ ssize_t hexagram_pcapng_read_options(hexagram_pcapng_stream *stream,
|
||||||
total += readlen;
|
total += readlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((readlen = handler(stream, type, option.code, option.length)) < 0) {
|
if ((readlen = handler(stream, type, option.code, option.length, data)) < 0) {
|
||||||
goto error_io;
|
goto error_io;
|
||||||
} else if (readlen < option.length) {
|
} else if (readlen < option.length) {
|
||||||
stream->error = HEXAGRAM_PCAPNG_ERROR_TRUNCATED;
|
stream->error = HEXAGRAM_PCAPNG_ERROR_TRUNCATED;
|
||||||
|
@ -79,7 +80,8 @@ void hexagram_pcapng_stream_destroy(hexagram_pcapng_stream *stream) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t hexagram_pcapng_stream_read(hexagram_pcapng_stream *stream,
|
ssize_t hexagram_pcapng_stream_read(hexagram_pcapng_stream *stream,
|
||||||
hexagram_pcapng_block_handler *handler) {
|
hexagram_pcapng_block_handler *handler,
|
||||||
|
void *data) {
|
||||||
hexagram_pcapng_block_header header;
|
hexagram_pcapng_block_header header;
|
||||||
hexagram_pcapng_block_footer footer;
|
hexagram_pcapng_block_footer footer;
|
||||||
ssize_t total = 0;
|
ssize_t total = 0;
|
||||||
|
@ -104,7 +106,7 @@ ssize_t hexagram_pcapng_stream_read(hexagram_pcapng_stream *stream,
|
||||||
|
|
||||||
expected = header.length - sizeof(header) - sizeof(footer);
|
expected = header.length - sizeof(header) - sizeof(footer);
|
||||||
|
|
||||||
if ((readlen = handler(stream, header.type, expected)) < 0) {
|
if ((readlen = handler(stream, header.type, expected, data)) < 0) {
|
||||||
goto error_io;
|
goto error_io;
|
||||||
} else {
|
} else {
|
||||||
total += readlen;
|
total += readlen;
|
||||||
|
|
Loading…
Add table
Reference in a new issue