Skip to content

Commit

Permalink
filed: avoid reading from ephemeral buffer
Browse files Browse the repository at this point in the history
In AddFileset() the item pointer can be passed to all kinds of functions
like plugin event handlers.
As dir->msg is only short-lived and can be overwritten when
communicating with the directory (e.g. emitting a job message), it is
safer to copy the buffer before passing it down.
  • Loading branch information
arogge authored and pstorz committed Feb 16, 2023
1 parent 76ff980 commit f1ce230
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/filed/dir_cmd.cc
Expand Up @@ -1273,7 +1273,7 @@ static bool FilesetCmd(JobControlRecord* jcr)
while (dir->recv() >= 0) {
StripTrailingJunk(dir->msg);
Dmsg1(500, "Fileset: %s\n", dir->msg);
AddFileset(jcr, dir->msg);
AddFileset(jcr, std::string{dir->msg}.c_str());
}

if (!TermFileset(jcr)) { return false; }
Expand Down

0 comments on commit f1ce230

Please sign in to comment.