The allocated 'Formatter' passed to the function should be
freed by the caller to avoid missusage.
If handle_asok_command() free's the pointer to 'Formatter' to pass
an indication of an error back to the caller, it should have at least
set the pointer to NULL to work anyway.
Fix for:
CID
1316253 (#1 of 1): Use after free (USE_AFTER_FREE)
deref_arg: Calling flush dereferences freed pointer f. (The dereference
happens because this is a virtual function call.)
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
dout(1) << "Can't run that command on an inactive MDS!" << dendl;
f->dump_string("error", "mds_not_active");
} else {
- handled = mds_rank->handle_asok_command(command, cmdmap, f, ss);
+ handled = mds_rank->handle_asok_command(command, cmdmap, f, ss);
}
-
}
f->flush(ss);
delete f;
if (!got_val) {
ss << "no target epoch given";
- delete f;
return true;
}
string path;
if(!cmd_getval(g_ceph_context, cmdmap, "path", path)) {
ss << "malformed path";
- delete f;
return true;
}
int64_t rank;
if(!cmd_getval(g_ceph_context, cmdmap, "rank", rank)) {
ss << "malformed rank";
- delete f;
return true;
}
command_export_dir(f, path, (mds_rank_t)rank);