-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
log-pcap: fix segfault on lz4 compressed pcaps #6875
Changes from 4 commits
e2f53ed
30960b2
ef7e4a5
4765356
c2bb99b
4fa3b55
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -412,12 +412,12 @@ static int PcapLogOpenHandles(PcapLogData *pl, const Packet *p) | |
} | ||
comp->file = fopen(pl->filename, "w"); | ||
if (comp->file == NULL) { | ||
SCLogError(SC_ERR_OPENING_FILE, | ||
"Error opening file for compressed output: %s", | ||
strerror(errno)); | ||
/* took this out so that it won't print twice, but still would function | ||
same SCLogError(SC_ERR_OPENING_FILE, "Error opening file for compressed output: | ||
%s", strerror(errno)); | ||
*/ | ||
return TM_ECODE_FAILED; | ||
} | ||
|
||
uint64_t bytes_written = LZ4F_compressBegin(comp->lz4f_context, | ||
comp->buffer, comp->buffer_size, NULL); | ||
if (LZ4F_isError(bytes_written)) { | ||
|
@@ -576,6 +576,12 @@ static int PcapLog (ThreadVars *t, void *thread_data, const Packet *p) | |
SCLogError(SC_ERR_FSEEK, "fseek failed: %s", strerror(errno)); | ||
return TM_ECODE_FAILED; | ||
} | ||
comp->file = fopen(pl->filename, "w"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see a check for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If |
||
if (comp->file == NULL) { | ||
SCLogError(SC_ERR_OPENING_FILE, "Error opening file for compressed output: %s", | ||
strerror(errno)); | ||
return TM_ECODE_FAILED; | ||
} | ||
if (fwrite(comp->buffer, 1, out_size, comp->file) < out_size) { | ||
SCLogError(SC_ERR_FWRITE, "fwrite failed: %s", strerror(errno)); | ||
return TM_ECODE_FAILED; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if removing output please just remove it instead of leaving it as a comment. It is fine to have a comment explaining why there is no error message here