[PATCH] Memory corruption in e4rat-collect
Brought to you by:
conso
Hi,
e4rat-collect saves collected data to a random file at / (or no file at all) instead of provided or default data path. This happens because const char* outPath
is being assigned to a volatile pointer of the string returned by Config::get<T>(arg).c_str(), instead of copying string. C strings can't be copyied by just = operator, strdup or other array copy tool should be used instead.
Provided patch fixes this problem.
IMHO much better solution is to actually keep around an instance of std::string, which, by design, manages the associated memory. With the current way it's needed to call
free()
on eachstrdup()
ed string. I'd recommend using std::string for local variablesexecute
,username
,outPath
and similar, too.Last edit: linuxtardis 2017-04-30