Skip to content

Commit ea7cd57

Browse files
committed
Fix rtapi_app: Sanitize name for module
1 parent c911956 commit ea7cd57

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/rtapi/uspace_rtapi_main.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,15 @@ static int do_comp_args(void *module, const std::vector<std::string> &args) {
220220
static int do_load_cmd(const std::string &name, const std::vector<std::string> &args) {
221221
void *w = modules[name];
222222
if (w == NULL) {
223+
//Sanitize the name
224+
if (name.find("/") != std::string::npos || name.find("..") != std::string::npos) {
225+
rtapi_print_msg(
226+
RTAPI_MSG_ERR,
227+
"%s: Not allowed as module name. Slashes or with \"..\" (even /a..b/) are not allowed.\n",
228+
name.c_str()
229+
);
230+
return -1;
231+
}
223232
std::string what;
224233
what = fmt::format("{}/{}.so", EMC2_RTLIB_DIR, name);
225234
void *module = modules[name] = dlopen(what.c_str(), RTLD_GLOBAL | RTLD_NOW);

0 commit comments

Comments
 (0)