Skip to content

executor::prepare_cmd_style has a bug traversing the PATH variable contents #121

@alloutlife

Description

@alloutlife

Splitting the PATH environ variable by a colons we have a path array containing the directories with the first entry erroneously preceded by a substring 'PATH='. If an executable invoked by boost::process::system( "" ) or boost::process:child( "") is expected to be located in that first PATH entry then executor::prepare_cmd_style() fails to build a full path to the executable. And this leads to process execution error.

In my example i have a "PATH=/usr/bin:/bin" and boost::process::child{ "wget" } fails with "No such file or directory" error because wget is located in /usr/bin.

The solution is to split the contents of the PATH variable not the full string "PATH=.."
The possible fix is to advance the *e pointer when boost::split() is invoked.

original [boost/process/detail/posix/executor.hpp]:
boost::split(path, *e, boost::is_any_of(":"));
change to:
boost::split(path, *e + 5, boost::is_any_of(":"));

, where 5 is the length of the "PATH=".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions