Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/topic/jsiwek/gh-1269'
Browse files Browse the repository at this point in the history
* origin/topic/jsiwek/gh-1269:
  GH-1269: Fix LogAscii::enable_leftover_log_rotation crash in bad dirs
  • Loading branch information
timwoj committed Nov 10, 2020
2 parents 2e57f84 + 0eb6839 commit 8722118
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@

3.3.0-dev.514 | 2020-11-10 14:05:51 -0700

* GH-1269: Fix LogAscii::enable_leftover_log_rotation crash in bad dirs

Running with that option enabled inside a bad directory (e.g. lack of
permissions) crashed due to not checking for failure of opendir(). (Jon Siwek, Corelight)

3.3.0-dev.512 | 2020-11-10 13:55:33 -0700

* Change Debian 10 CI config to use GCC (Jon Siwek, Corelight)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.0-dev.512
3.3.0-dev.514
15 changes: 15 additions & 0 deletions src/logging/writers/ascii/Ascii.cc
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,21 @@ static std::vector<LeftoverLog> find_leftover_logs()
auto d = opendir(".");
struct dirent* dp;

if ( ! d )
{
char cwd[PATH_MAX];

if ( ! getcwd(cwd, sizeof(cwd)) )
{
cwd[0] = '.';
cwd[1] = '\0';
}

reporter->Error("failed to open directory '%s' in search of leftover logs: %s",
cwd, strerror(errno));
return rval;
}

while ( (dp = readdir(d)) )
{
if ( strncmp(dp->d_name, shadow_file_prefix, prefix_len) != 0 )
Expand Down

0 comments on commit 8722118

Please sign in to comment.