Description
The constructor of Executor in src/slave/slave does not make sure that the member variable commandExecutor is always set. The following logic is used to determine its value,
Result<string> executorPath =
os::realpath(path::join(slave->flags.launcher_dir, MESOS_EXECUTOR));
if (executorPath.isSome()) {
commandExecutor =
strings::contains(info.command().value(), executorPath.get());
}
Should we fail to determine the realpath of the mesos executor, commandExecutor will not be set. Since commandExecutor is a scalar field, no default initialization happens and its value will be random memory (which might often evaluate to true).
We need to make sure the member variable is set on all branches. Looking at the code it seems we might be able to just explicitly assert some executorPath.
This was pointed out by coverity, https://scan5.coverity.com/reports.htm#v10074/p10429/fileInstanceId=100298128&defectInstanceId=28784922&mergedDefectId=1373526.