mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
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().
This commit is contained in:
parent
8337b4cf2d
commit
0eb6839dae
1 changed files with 15 additions and 0 deletions
|
@ -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 )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue