using strncpy could possibly lead to a non null terminated string. also some coding style fix. CID 2216.