coverity#17930 Copy into fixed size buffer

rework as std::string
coverity#25609 Resource leak
coverity#25608 Dereference after null check
coverity#17913 Copy into fixed size buffer
coverity#17905 Copy into fixed size buffer
coverity#17904 Copy into fixed size buffer
coverity#17914 Copy into fixed size buffer
coverity#17915 Copy into fixed size buffer