Potential order or argument evaluation problem: if getuid() and getgid() are called (again) before GetErrorStr() is called, something might have set errno to a value other than the one chown left you.  One way out is to save getuid() and getgid() returns in local variables just before calling chown on them, then re-using the values here; another would be to call GetErrorStr() before Log() and save its return in an even more local variable.