Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

cleanup(libscap): Allow retries after encountering SCAP_EOF #1809

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion userspace/libscap/engine/savefile/scap_reader_gzfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,22 @@ typedef struct reader_handle
static int gzfile_read(scap_reader_t *r, void* buf, uint32_t len)
{
ASSERT(r != NULL);
return gzread(((reader_handle_t*)r->handle)->m_file, buf, len);
int readsize = gzread(((reader_handle_t*)r->handle)->m_file, buf, len);

if (readsize < (int)len && readsize != -1)
{
int errnum;
gzerror(((reader_handle_t*)r->handle)->m_file, &errnum);
if (errnum == Z_OK || errnum == Z_BUF_ERROR)
{
// We've reached the end of input. This isn't necessarily an
// error, e.g. if we're tailing a file that's being written by
// another process, so allow for retries.
gzclearerr(((reader_handle_t*)r->handle)->m_file);
}
}

return readsize;
}

static int64_t gzfile_offset(scap_reader_t *r)
Expand Down
Loading